This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

📣 Join the live AMA session with Adam Silverstein on open source and WordPress core! Register Now →

Magento 500 Internal Server Error – 4 Reasons Why It Shows up and How to Fix It?

Updated on August 9, 2023

7 Min Read
error 500 magento

Server errors are among the most common Magento errors, especially of the Magento 500 variety.  Wrangling up with an HTTP 500 internal server error can eat away at your precious time and resources. In light of that, let’s dive into the most likely causes behind these errors, and the solutions that developers should use to overcome these.  

What is Magento 500 Internal Server Error?

The Magento 500 internal server error is a general HTTP status code that can often crop up when you’re deploying or updating the website. This indicates the server is experiencing something wrong.             

Sometimes, the Magento 500 error is quickly fixed by refreshing the page. But when that doesn’t resolve the problem right away, you may have to troubleshoot to fix the issue.

Let’s check out the possible reasons behind this sort of error.

Why Does the Magento 500 Error Occur?

There are 4 potential issues that may cause this error.

  • Permission Issues: When you haven’t set your permissions according to Magento’s strict requirements, this error might happen.
  • Memory Limitation: Magento consumes a lot of resources, and it may be that you don’t have enough memory to handle those resources.
  • Issue in .htaccess file: A Magento store migrated from the localhost to any other server with the wrong configuration can result in Magento internal server error. Magento accesses the .htaccess file first, so any misconfiguration can lead to the server experiencing the Magento 500 error.
  • Third-Party Plugin Issues: The third-party extensions that you install might not be compatible with the server configuration.

Operating Magento Stores is Breezy with Cloudways!

Cloudways has a specialized hosting solution for Magento stores that includes advanced cache, HTTP/2 support, IP whitelisting, and many more features. Signup on Cloudways and let server-side issues be a thing of past!

Possible Fixes for Magento 500 Error

Before troubleshooting, enable developer mode in Magento 2 to uncover the cause of the error. To do so, run the following command:

php bin/magento deploy:mode:set developer

Here’s how to resolve the Magento 500 error.

1. Fix the File Permissions

The Magento 2 directory structure contains standard file and folder permissions. But when you install an extension or update to Magento 2 on the server, it changes those permissions. That causes the appearance of the Magento 500 internal server error when logging in to the admin panel. 

To fix this, change the file permissions of index.php in the root file from 664 to 644 through your website’s file manager. Resetting permissions can fix the Magento 500 error. 

Please run the following commands to set the permissions:

find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
find ./var -type d -exec chmod 777 {} \;
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
chmod u+x bin/Magento

Still stuck? Cloudways provides the easiest way to reset the file permissions.

How do you fix the file permissions in Cloudways?

  1. Log in to your Cloudways Platform with your credentials.
  2. From the top menu bar, open Applications.
  3. Choose your desired application.

applications cloudways

  1. Select Application Settings.

application settings

  1.  Scroll down to the General tab to see the option to ‘Reset File/Folders Permissions’. Check the dropdown next to this option to choose the desired user (master or application user).

rest files

  1.  Click to reset the file permissions that you want to set.
  2. Click on “Save Changes”.

Verify the permissions and then refresh the page to check if the 500 error is gone.

2. Fix Memory Limitations

The 500 Magento internal server error may appear on the product or checkout page of the Magento 2 website  when your server is unable to provide the resources to respond on request. To address this, increase the memory limit in the php.ini file or .htaccess file.

For the .htaccess file, write or change the lines as shown below:

<IfModule mod_php5.c>
php_value memory_limit 256M
</IfModule>
For the php.ini file, add or change the the lines as shown below, based on server health:
memory_limit = 1024M

If you are unable to make these changes due to a lack of permissions on your server, ask the hosting provider to make these changes.

There’s an easier way to fix memory limitations with Cloudways.

How do you fix the memory limit in Cloudways?

  1.  Under Server, select Settings & Packages.

settings and packages

  1.  Under the Basic Settings, configure the memory limitation as per need.

basic

  1. Click “Save Changes”.
  2. Refresh the page again.

3. Fix Issues with the .htaccess File

To fix a 500 internal server error caused by the wrong configuration in the .htaccess file, try renaming or removing the .htaccess file and reloading the website again to check if the error is fixed.

If the Magento 500 internal server error is fixed, then there is some configuration issue with the .htaccess file that needs to be fixed. Take care to avoid any issues with broken 404 links in your store with this fix.

4. Fix Third-party Plugin Issues

You might be experiencing the Magento internal server error due to the installation of a third-party extension, or an extension upgrade that enables maintenance mode or creates version compatibility issues after configuration.

To fix this just need to disable the mod by running the following command

php bin/magento mod:disable

Or contact your extension support team to fix it.

Magento Stores Should Never Lose Customers Because of Server-Side Issues!

Cloudways offers optimized hosting for Magento stores that includes advanced cache, HTTP/2 support, IP whitelisting, and many more features. Signup on now and rid your Magento stores from server-side issues!

5. Disable Magento Maintenance Mode

The 500 internal server errors can appear during maintenance mode. Developers often enable the maintenance mode to deploy a website to the other server, by putting the “maintenance.flag” file into the root folder and changing the permissions of index.php to 666.

To fix this, disable the maintenance mode by removing the maintenance.flag file or running the following command:

php bin/magento maintenance:disable

After this, change the index.php file permissions to 755, and clear the cache of your Magento 2 store.

Use the command blow to change permissions of index.php:

chmod 775 -R index.php

6. Fix the PHP Version Issue

Your PHP version might not be compatible with the server configuration. Check the logs to see what compatible version you need based on your requirements and install it.

Try the below command for PHP update version from ssh:

sudo apt update

sudo apt install php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath

How do you fix the PHP version issue in Cloudways?

  1. Under Server Management, select Settings & Packages.
  2. Under the Packages tab, select the PHP version from the dropdown.

packages

  1. Click Save Changes.

Note: Cloudways offers the latest version of PHP for all users.

php versions

7. Fix Missing Extensions

Missing extensions or modules in your server or PHP configuration might be behind your internal 500 server errors. Find out which extension is missing and install it to resolve the error.

Installing CURL Extension

To install and fix the missing CURL extension, use the command below:

Sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

8. Fix Missing Modules

Magento runs heavily on modules. They may be used to enhance functionality, for payment gateways, or for the core functionality of a Magento website or store. Because of Magento’s heavy dependence on modules, there’s a risk of error 500 involved.

Either a certain module might crash or become unresponsive. Or because your server could be unsupportive to the installation because of some missing modules. You can circumvent this issue by identifying the missing modules and arranging them so that the error can be resolved.

9. Check Server Error Logs

Check the log files to identify the actual problem.

Fixing Apache Logs

To resolve missing configuration on your server or invalid commands in a server configuration error, check the web server logs need to be checked.

For Apache, the logs directory:

/var/log/httpd/ -> centos
/var/log/apache2/ -> debian, ubuntu

Directory List of Error Log

The Magento 2 Logger can help you determine which log file you need to debug for the problem. Enabling developer mode to reload the website, and check the error log of the Magento 2 store in the var/log directory.

10. Run Magento 2 All Commands

The Magento 500 server error could be resolved by running the following lines:

rm -rf generated/*
rm -rf var/*
cd pub/static
rm -r adminhtml
rm -r frontend
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f
php bin/magento indexer:reindex
php bin/magento cache:clean
php bin/magento cache:flush

Concluding Words

Avoid the Magento 500 error by being careful during store maintenance. Make sure you use the right file permissions in the Magento root directory. Make and follow a set of guidelines before upgrading or installing an extension that causes issues. Also Magento 503 error could be the cause for server error too.

If, after following the steps in this article, you’re still unable to resolve this error, contact your hosting provider.

FAQs

What is a 500 internal server error?

The HTTP 500 internal server error is a response code that indicates your server is experiencing trouble.

How to bypass HTTP Error 500?

You can bypass HTTP error 500 by clearing the cache and deleting your browser’s cookies. Once that’s done, restart the browser and you’ll very likely bypass the HTTP 500 error.

How can you fix the HTTP error 500 in Magento 2?

Investigate the actual cause behind the error, and implement these solutions one by one:

  • Change Magento File Permissions
  • Fix Memory Limitation
  • Rename or remove .htaccess file
  • Disable Maintenance Mode
  • Fix Missing Extension
  • Fix PHP Version
  • Fix Third Party Extension Issues
  • Check Web Server Error Logs
  • Run All Commands
Share your opinion in the comment section. COMMENT NOW

Share This Article

Sarim Javaid

Sarim Javaid is a Digital Content Producer at Cloudways. He has a habit of penning down his random thoughts and giving words and meaning to the clutter of ideas colliding inside his mind. His obsession with Google and his curious mind add to his research-based writing. Other than that, he's a music and art admirer and an overly-excited person.

×

Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!

×

Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Want to Experience the Cloudways Platform in Its Full Glory?

Take a FREE guided tour of Cloudways and see for yourself how easily you can manage your server & apps on the leading cloud-hosting platform.

Start my tour

CYBER WEEK SAVINGS

  • 0

    Days

  • 0

    Hours

  • 0

    Mints

  • 0

    Sec

GET OFFER

For 4 Months &
40 Free Migrations

For 4 Months &
40 Free Migrations

Upgrade Now