[Ubuntu 18.04 / Apache 2.4 / PHP 7.2.17 / Magento 2.3.1]

After successful installing, magento show blank page. I found following error in apache error.log:

[php7:error] [pid 29252] [client] PHP Fatal error: Uncaught RuntimeException: Can't create directory /var/www/html/magento/generated/code/Magento/Framework/App/ResourceConnection/.\nClass Magento\Framework\App\ResourceConnection\Proxy generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. in /var/www/html/magento/vendor/magento/framework/Code/Generator.php:135\nStack trace:\n#0 /var/www/html/magento/vendor/magento/framework/Code/Generator/Autoloader.php(35): Magento\Framework\Code\Generator->generateClass('Magento\\Framewo...')\n#1 [internal function]: Magento\Framework\Code\Generator\Autoloader->load('Magento\\Framewo...')\n#2 [internal function]: spl_autoload_call('Magento\\Framewo...')\n#3 /var/www/html/magento/vendor/mag in /var/www/html/magento/vendor/magento/framework/Code/Generator.php on line 135

I have set chmod -R 777 /var/www/html/magento/generated. But it's showing the same error. Can you help?

1 Answer 1


You have to give permissions to var pub and generated directories. cd into your magento installation and run following command;

chmod -R 777 var pub generated

you may also need to run setup upgarade and deploy static files so run following commands too ;

php bin/magento s:up && php bin/magento s:s:d -f && chmod 777 -R  var pub generated
  • Thank you very much. But now I have new error: There has been an error processing your request /var/www/html/magento/var/report {"0":"SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'","1":"<pre>#1 Zend_Db_Adapter_Pdo_Mysql->_connect() called at [vendor\/magento\/framework\/DB\/Adapter\/Pdo\/Mysql.php:406]\n#2 Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql->_connect() called at [vendor\/magento\/zendframework1\/library\/Zend\/Db\/Adapter\/Abstract.php:460]\n#3 Zend_Db_Adapter_Abstract->query('SELECT `store_we...', array()) called at...
    – mashuxa
    Commented Apr 14, 2019 at 11:27
  • you may not have connected to your db correctly. Enter your db user credentials and correct db in {magento_root}/app/etc/env.php Commented Apr 14, 2019 at 11:31
  • Also please accept the answer if it helped Commented Apr 14, 2019 at 11:32
  • Thank you very much. It works. Also problem was related with root user's password. I created new user with strong password and magento started!
    – mashuxa
    Commented Apr 14, 2019 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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