I have installed magento 2 on a local network (for example, and it is a virtual machine)

i was having some permission problems, had to run sudo php bin/magento setup:static-content:deploy

to create all css js required; public area looks fine but when i try to access mi admin url ( i get an error which is this: http://www.heypasteit.com/clip/2DKT

Could be a permission problem? right now all folder and file are own by root but folers var pub and app/etc are owned by the web user (www-data) with the right permissons

or maybe some file where not copied?

  • You try set permission 777(755) for <magento_dir>/var folder
    – Thao Pham
    Jan 5, 2016 at 13:30
  • Still gives the same error :( Jan 5, 2016 at 14:57

4 Answers 4


In my case, it was the issue with var/generation directory. Magento 2 creates Factory classes and stores in this directory.

I cleared var/generation directory and set it's ownership as that of var/cache and var/page_cache directory. And, now the issue is solved. I am able to login to admin again.


Magento\Authorization\Model\RoleFactory refers to Magento\Authorization\Model\Role which should be located in vendor/magento/module-authorization/Model/Role.php. If this file is not available, than that's your problem.

  • The file is there, with this file permissions -rw-r--r-- 1 www-data www-data 3066 nov 17 01:55 Role.php, this is not correct? Jan 7, 2016 at 8:53

I cleared cache and deployed again as follows, and finally was able to login:

sudo php -f bin/magento cache:clean

sudo rm -rf pub/static/*; 
sudo rm -rf var/*/*; 
sudo php -f bin/magento setup:static-content:deploy en_US en_CA

sudo chown -R :www-data .
sudo find ./var -type d -exec chmod 777 {} \;
sudo find ./pub/media -type d -exec chmod 777 {} \;
sudo find ./pub/static -type d -exec chmod 777 {} \;

If directory owner is different, use it instead of "www-data".


It worked for me after removing var/generation and login again. later var/generation created automatically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.