When working with Magento, sometimes you will see the error Magento 500 Internal Server Errors when updating/installing or removing Magento or Magento 2 components, such as: Themes, plugins, patches… or 500 internal server error after system backup, on product page, on admin login, after performing Magento upgrade, or after install Magento. The error looks like this:
Magento 500 Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, firstname.lastname@example.org and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
In this tutorial, I will list all the possible causes and solutions to fix this error.
Enable Developer mode
Developer mode allows you to debug Magento to see detail exceptions on error page instead of showing a generic error message like “There has been an error processing your request, Magento exception printing is disabled by default for security reasons“. or 500 Internal Server Errors.
Enable developer mode in Magento 1
Open your site’s index.php file and uncomment these lines
Save the file file and now your index.php file will look as below
Now clear cache and reload your error page to see detail of the error.
Enable developer mode in Magento 2
Open your ssh client and enter the following command
php bin/magento deploy:mode:set developer
Another way is that you can Set the web-server variable MAGE_MODE to the value developer . For example, in Apache, add the following code to your .htaccess file:
SetEnv MAGE_MODE "developer"
for Nginx users, changing htaccess file won’t work, you need to add set $MAGE_MODE developer; to nginx.conf file as below:
set $MAGE_ROOT path/to/magento2;
set $MAGE_MODE developer;
A not-recommended option is that you can also enable developer mode via index.php file of Magento 2 by adding this line to index.php:
$_SERVER['MAGE_MODE'] = 'developer';
Now the error is displayed, we need some solution to fix this error.
Solution 1: Changing Magento file permission
We usually see Magento 500 Internal Server Errors when logging to admin panel, to solve this go to file manager of your Magento website and change permission of index.php file in root from 664 to 644
You should also change permission of another index.php file located in downloader/index.php to 644, otherwise you will see 500 internal server error when navigating to System > Magento Connect >Magento Connect Manager.
Solution 2: Increase php_value memory_limit
When you see the error in a specific page of your Magento site like checkout page, product page, this may be because your server are lacking of resource to run Magento. For a store with ~500 products, it’s recommended to have at least 256M for php_memory_limit value. You can this value via .htaccess file or php.ini file
For .htaccess file
Add the following lines
php_value memory_limit 256M
For php.ini file
Add/change the following line
memory_limit = 256M
If you can’t change your self due to lack of permission on hosting, ask your hosting provider, or you can pick a hosting from this list of best optimized Magento hosting to avoid lack of resource.
Solution 3: rename/remove .htaccess file
Sometimes the error is simply caused by wrong settings in .htaccess file, for example: wrong url rewrite/redirect setting. You can try renaming/removing .htaccess file to check if the error is gone
You can read this article to learn how to optimize .htacess file for better Magento load speed
Solution 4: Disable Magento maintenance mode
Maintenance mode in Magento can be enabled by put maintenance.flag file in Magento root folder (learn more). The maintenance mode also changes file permission of index.php to 666, which makes it unable to executed by web browers.
Disable maintenance mode in Magento 1
Go to root folder of Magento and remove Maintenance.flag file.
Disable maintenance mode in Magento 2
Remove var/.maintenance.flag file or run this command from your ssh
php bin/magento maintenance:enable
Next, change permission for index.php to 755 and clear cache to see if the error is fixed
Solution 5: install CURL extension for your server
Sometimes missing CURL extension may cause Magento 500 internal error. You can install CURL extension by running the following command via ssh (Centos)
yum install curl libcurl3 libcurl3-dev php5-curl
Next, restart httpd to apply changes
service httpd restart
Still see the error?
Drop a line here to describe your issue and we will see if we are able to help you