Environment: Magento2 2.2.5 / PHP 7.0.28

Fatal error: Uncaught RuntimeException: Can't create directory /opt/lampp/htdocs/Procfit-Institucional/generated/code/Magento/Framework/App/ResourceConnection/. in [Magento\Framework\App\ResourceConnection\Proxy] in /opt/lampp/htdocs/Procfit-Institucional/vendor/magento/framework/Code/Generator.php:115 Stack trace: #0 /opt/lampp/htdocs/Procfit-Institucional/vendor/magento/framework/Code/Generator/Autoloader.php(35): Magento\Framework\Code\Generator->generateClass('Magento\Framewo...') #1 [internal function]: Magento\Framework\Code\Generator\Autoloader->load('Magento\Framewo...') #2 [internal function]: spl_autoload_call('Magento\Framewo...') #3 /opt/lampp/htdocs/Procfit-Institucional/vendor/magento/framework/Code/Reader/ClassReader.php(19): ReflectionClass->__construct('Magento\Framewo...') #4 /opt/lampp/htdocs/Procfit-Institucional/vendor/magento/framework/ObjectManager/Definition/Runtime.php(44): Magento\Framework\Code\Reader\ClassReader->getConstructor('Magento\Framewo...') #5 /opt/lampp/htdocs/Procfit-Institucion in /opt/lampp/htdocs/Procfit-Institucional/vendor/magento/framework/Code/Generator.php on line 115

I already tried:

sudo chmod 777 -R on my root project 
sudo chmod -R 777  var/*

Try to launch in your magento directory :

sudo find . -type d -exec chmod 770 {} \; && sudo find . -type f -exec chmod 660 {} \; && sudo chmod u+x bin/magento

It will fix perm like Magento documentation.

|improve this answer|||||

Give permission to generated folder

chmod 777 -Rf generated/* var/*

After flush cache

php bin/magento cache:flush
|improve this answer|||||
  • Thank you for comment, i tried that but still the same error – Caio Pereira Aug 30 '18 at 15:23
  • updated answer please try this – Prashant Valanda Aug 30 '18 at 15:26
  • It still the same error, i gave permissions for generated/* , var/* – Caio Pereira Aug 30 '18 at 15:33

Give permissions to the generated folder


  1. Go To - cd /opt/lampp/htdocs
  2. sudo chmod 777 -R magento (or Your Package folder name).

Then Check

|improve this answer|||||

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.