500 after install – Class MagentoFrameworkAppResourceConnectionProxy does not exist

The question:

I installed Magento2 successfully through the commandline, but when i try to access the website, i get a Server Error 500.

The server runs on Ubuntu 14.04

I have no idea what is wrong, or what i am doing wrong.
I used a script to install Magento2 so i expect it to be correct

PHP Errors:

[Wed Mar 02 17:03:18.718890 2016] [:error] [pid 2292] [client] PHP Fatal error: Uncaught exception ‘ReflectionException’ with message ‘Class MagentoFrameworkAppResourceConnectionProxy does not exist’ in /var/www/html/vendor/magento/framework/Code/Reader/ClassReader.php:19nStack trace:n#0 /var/www/html/vendor/magento/framework/Code/Reader/ClassReader.php(19): ReflectionClass->__construct(‘Magento\Framewo…’)n#1 /var/www/html/vendor/magento/framework/ObjectManager/Definition/Runtime.php(44): MagentoFrameworkCodeReaderClassReader->getConstructor(‘Magento\Framewo…’)n#2 /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(71): MagentoFrameworkObjectManagerDefinitionRuntime->getParameters(‘Magento\Framewo…’)n#3 /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php(71): MagentoFrameworkObjectManagerFactoryDynamicDeveloper->create(‘Magento\Framewo…’)n#4 /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(236): MagentoFrameworkObjectManagerObjectManager->get(‘Magento\Framewo…’)n#5 /var/ww in /var/www/html/vendor/magento/framework/Code/Reader/ClassReader.php on line 19

and this multiple times

[Wed Mar 02 17:03:18.718739 2016] [:error] [pid 2292] [client] PHP Warning: include(): Failed opening ‘/var/www/html/var/generation/Magento/Framework/App/ResourceConnection/Proxy.php’ for inclusion (include_path=’/var/www/html/var/generation:/var/www/html/lib/internal:/var/www/html/var/generation:/var/www/html/lib/internal:/var/www/html/vendor/phpseclib/phpseclib/phpseclib:/var/www/html/vendor/magento/zendframework1/library:/var/www/html/vendor/phpunit/php-file-iterator:/var/www/html/vendor/phpunit/phpunit:/var/www/html/vendor/symfony/yaml:.:/usr/share/php:/usr/share/pear’) in /var/www/html/vendor/magento/framework/Code/Generator/Io.php on line 158


[Wed Mar 02 17:03:18.718377 2016] [:error] [pid 2292] [client] PHP Warning: include(): Failed opening ‘/var/www/html/var/generation/Magento//Framework/App/ResourceConnection/Proxy.php’ for inclusion (include_path=’/var/www/html/var/generation:/var/www/html/lib/internal:/var/www/html/var/generation:/var/www/html/lib/internal:/var/www/html/vendor/phpseclib/phpseclib/phpseclib:/var/www/html/vendor/magento/zendframework1/library:/var/www/html/vendor/phpunit/php-file-iterator:/var/www/html/vendor/phpunit/phpunit:/var/www/html/vendor/symfony/yaml:.:/usr/share/php:/usr/share/pear’) in /var/www/html/vendor/composer/ClassLoader.php on line 412

Also, this is the core_config_data from the magento database

enter image description here

Any idea what i could try?

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

chown -R www-data:www-data /var/www/magento2/ 
chmod 777 -R var
chmod 777 -R generated
chmod 777 -R app/etc
rm -rf var/cache/* var/page_cache/* var/generation/*


php bin/magento setup:di:compile;

Method 2

Delete composer autoload (vendor/autoload.php) as suggested by @JELLEJ and type composer install in magento root folder to recreate it.

It worked for me on Magento 2.3.5-p1 (but should work in other versions).

Method 3

several classes in Magento2 are generated dynamically. Except you are in Developer mode, this does not happen automatically.

To activate the developer Mode, you have to uncomment the Line in the beginning of your .htaccess file.

For production and default mode you have to execute the command bin/magento setup:di:compile from your magento root to generate the classes

Method 4

In case you are facing this issue whilst the permission set correctly already and mainly use RHEL/CentOS, you may be facing issues with files security context SElinux, as per the docs here, you may need to change the security context due to SElinux configuration on your root directory as following:


chcon -R --type httpd_sys_rw_content_t <magento_root>/app/etc


chcon -R --type httpd_sys_rw_content_t <magento_root>/var


chcon -R --type httpd_sys_rw_content_t <magento_root>/pub/media


chcon -R --type httpd_sys_rw_content_t <magento_root>/pub/static


chcon -R --type httpd_sys_rw_content_t <magento_root>/generated

This will make SElinux allow access from nginx/apache to your magento files.

Method 5

  • First reason could be you have installed PHP 8 and Magento2 is not compatible with it yet. So to resolve this, you need to use PHP 7.4.
  • Other reason we need to find with below steps:
    • Open the bootstrap.php file present in the app folder of magento directory.
    • Remove # from the beginning of the line
      #ini_set(‘display_errors’, 1);
    • Save the file and refresh your browser to see the exact issue.

Happy Learning !!
Thank You !!

Method 6

Sharing below one-time steps ideally for the local setup, especially stand-alone Magento setups.

Commands mainly for Ubuntu-based.

  1. Use whoami command to find out which user is currently on. Mostly you will get non-root users.
[email protected]:/var/www/html$ whoami

Should output as below:

  1. Optional: Below one only requires if you are on non root
    Switch to non-root user(magento).
[email protected]:/var/www/html$ sudo -u magento /bin/bash
  1. Run below command to get the current user, should give magento as we have changed the user to magento
[email protected]:/var/www/html$ echo "$USER"
  1. Give current user(magento) to www-data group as a secondary user
[email protected]:/var/www/html$ sudo usermod -a -G www-data $USER
  1. Change ownership to directory
[email protected]:/var/www/html$ sudo chown -R $USER:www-data /var/www/html/

Ownership can be given to the someotheruser user as well. Make sure to give to non-root users.

  • Worked well for me to resolve this error on various installations Magento 2.3.x to Magento 2.4.x.

  • This can resolve the above error if you are facing the same every time after running some bin/magento commands especially setup:upgrade or setup:di:compile

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment