When you update, install, or remove a component such as theme, patches, plugins,…  on your Magento or Magento 2 website, you might encounter the error “Magento 500 Internal Server Errors”. The error is also likely to occur after you performing Magento upgrade, or after install Magento, or after system backup, on product page, on admin login.

Magento 500 error

In this article, all the possible causes and solutions to fix this error will be listed for you.

Enable Developer mode

Before doing anything, you first have to Enable Developer Mode.

It is “Developer mode” that allows you to debug Magento, which means it allows you to see detail exceptions on your error page, not just messages like “There has been an error processing your request”, “Magento exception printing is disabled by default for security reasons”, or “Magento 500 Internal Server Error”.

In Magento 1

Open your site’s index.php file and uncomment these lines:

#Mage::setIsDeveloperMode(true);
#ini_set(‘display_errors’, 1);

Save the file and now your index.php file will look like this:

enable developer mode Magento

Now clear cache and reload your error page to see detail of the error.

In Magento 2

Open your ssh client and enter the command like this:

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:

server {
 listen 80;
 server_name magento.magentoexplorer.com;
 set $MAGE_ROOT path/to/magento2;
 set $MAGE_MODE developer;
 include other/configurations/file.conf;
}

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. Let’s fix the error for your Magento website.

Solution 1: Change Magento file permission

It’s common to 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:

change file permission Magento

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

Sometimes, you might 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 around 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:

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

For php.ini file, please add/change the following line:

memory_limit = 256M

Due to the lack of permission on hosting, you might not change it yourself so 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

In some situations, the error might be caused by wrong settings in .htaccess file, for example: wrong url rewrite/redirect setting. If that is the case, you can try renaming/removing .htaccess file to check if the error is fixed.

remove maintenance.flag

Solution 4: Disable Magento maintenance mode

Maintenance mode in Magento can be enabled by putting 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 browsers.

In Magento 1

Go to root folder of Magento and remove maintenance.flag file.

remove .htaccess file

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 still there.

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

Then, check again if the error is fixed.

 

See also:
Magento Upload HTTP Error
How to solve Magento error: Cannot initialize the indexer process

How to Fix 500 Internal Server Error in Magento
3.7 (73.33%) 3 votes
SHARE
A knowledge craver who always strive to be wiser everyday.

LEAVE A REPLY