How to fix 500 internal server error in Magento 2

500 internal server error is very common error during magento installation or server migration

Mostly we have this issue because of these 5 reasons

permissions issues

memory limitation

issues in the .htaccess file

missing modules

third-party plugin issues

Before making any change we would like to recommend you switch your magento side to developer mode you can do this by writing this command bin/magento deploy:mode:set developer

  1. Permissions error
    We face 500 internal server error in magento because of wrong file or folder permission. You can face this issue if your folder or file not have correct permission, you can give this permission by following command
    Go to root folder of your magneto you can right CD root-folder-name
cd <your Magento install dir> (Skip this if your are in root      folder)
find . -type f -exec chmod 644 {} \; // 644 permission for files
find . -type d -exec chmod 755 {} \; // 755 permission for directory
chown -R :<web server group> .
chmod u+x bin/magento

2. Memory limitation

go to the php.ini file and add:

memory_limit = 756M

756M is the minimum value you can set more memory volume.

Otherwise, add this code to the .htaccess file:

<IfModule mod_php5.c>
php_value memory_limit 756M
</IfModule>

3. Issues in the .htaccess file

Usually, problems with the .htaccess file happen when you are trying to run the installation of some components, such as themes, plugins, patches, etc. If you have some configuration mistakes, you can get the 500 error on the Magento website.

In this case, you can temporarily rename this file and check error logs in /var/log/httpd or /var/log/apache2. If you find any other issues, correct the configurations. 

4. Missing modules

Sometimes you can get the internal server error during Magento installation because your server doesn’t support some of the specifications. In this situation, you can use the Magento Check (https://example.com/magento/magento-check.php) to find out what modules are missing and then install them on the server.

5. Third-party plugin issue

If you are facing an issue after installing of extension you should contact your vendor or check compatibility of extension. In this case, use the following command php bin/magento mod:disable to turn off the mod

Share this post