The Most Popular Extension Builder for Magento 2

With a big catalog of 224+ extensions for your online store

How to Fix 500 Internal Server Error in Magento 2?

Magento 2 500 Internal Server Error is the most popular issue in the hosting environment. It is a result of installing, upgrading or removing Magento components such as themes, extensions, patches, etc. Suppose you don’t fix this issue soon, it may cause a loss in traffic and directly impact the customer experience when visiting your store.

500 Error in Magento is also similar to the issue when you install or upgrade Magento, or backup the system on the product page and login admin page. When you have to face a 500 error in Magento 2, you need to fix it as fast as possible.

This topic will help you understand the reason why 500 Error occurs as well as How to fix 500 Internal server errors in Magento 2.

Now, without further ado, let’s jump right into the details!

What does Magento 500 internal error mean?

When you click on a URL with the correct address or click on the link of a certain website, you immediately ask the server to display the page you are looking for. However, for some reason, the server cannot respond to the requested page and reports that you are experiencing an internal server error. I can be sure that all of us have encountered this error at least once.

Magento 2 Internal Server Error is a general HTTP status code. It means that something has gone wrong; however, the server couldn’t identify what the exact issue is. However, Magento 2 500 Error can be temporary and will disappear as soon as you reload the page. On the contrary, if you refresh the page, but this error does not go away, you need to calm down and fix this error soon.

To better understand the 500 Internal server errors in Magento 2, the first thing you need to do is check the server error logs for more information about this error.

Reason for the occurrence of Magento 2 500 internal server error

There is no denying the serious impact that 500 Internal Server Error can have on your website. However, you must always stay calm and find the cause to fix this error as quickly as possible.

In this article, we will list 7 main reasons why your website gets 500 Internal server errors in Magento 2.

  • Permissions issues: Files or folders within Magento might lack the necessary permissions for the server to access and execute them correctly.

  • Memory limitation: The server might not have enough allocated memory to handle the Magento operations, leading to errors.

  • Issues in the .htaccess file: This file, crucial for website configuration, might contain errors or misconfigurations that disrupt server functionality.

  • Missing modules: Essential Magento modules might be absent or incorrectly installed, causing the errors.

  • Third-party plugin issues: Conflicts or compatibility problems with third-party extensions can also trigger 500 errors.

  • Magento maintenance mode: If enabled, it can intentionally trigger a 500 error to prevent access while maintenance is underway.

  • Install CURL extension: Magento relies on this PHP extension for various tasks, and its absence can cause errors.

Important

Before doing anything, you need to enable Developer Mode. It allows you to debug Magento and see all detailed exceptions on your error page.

For Magento 2, you can enable Developer Mode by running the following command line:

bin/magento deploy:mode:set developer

Let’s explore some ways to fix Magento 2 500 Internal Server Error right now.

How to fix Magento 2 500 Internal Server Error?

1. Change Magento file Permission

fix Magento 2 500 Internal Server Error
Change Magento file Permission

Permission Error is one of the most common issues in 500 Internal Server Error, which happens when you log into the admin panel. To fix this error, you need to change Magento file permissions of index.php file from root 664 to 644.

Now, you need to run the following commands one by one. Afterward, this issue can be resolved.

cd <your Magento install dir>
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. Increase Php_value Memory_limit

Occasionally, Memory limit can occur on a specific page of your web stores, such as Checkout Page or Product Page. This is also a prevalent issue in Magento 500 Server error. It’s suggested to have at least 256M for php_memory_limit value if your store has around 500 products. However, there is no difficulty in checking this problem via the .htaccess file or php.ini file.

In case you only need to increase the volume.

Please add the following lines for php.ini file:

memory_limit = 256M

Otherwise, for .htaccess file,please add the following lines:

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

Overall, you can not do it by yourself because of the lack of permission on hosting. So you need support from your hosting provider, or you can choose the best Magento 2 hosting providers for your Magento store.

3. Issues in the .htaccess file

Usually, the issue in the .htaccess file may happen after you try to run the installation of some elements like themes, plugins, apps, etc. If you get this error on your website, it means that your Magento store gets 500 error.

For now, please try renaming or removing the .htaccess file to check whether this issue is fixed or not.

4. Missing modules

In some situations, you may get 500 error during Magento installation because your server does not support some specifications. Don’t worry too much about this case, it’s straightforward to solve. Please use Magento Check (https://yourdomain.com/magento/magento-check.php) to find the module you missed, then install it on your server to fix this error.

5. Third-party plugin issue

Another common error you may encounter is after installing or updating a plugin for your Magento store. It is a conflict that occurs between the new plugin and the plugins available in your store. In case, please run the below command to turn off the mod and contact the module support team as soon as possible to get assistance.

php bin/magento mod:disable

6. Disable Magento maintenance mode

disable magento maintenance mode
Disable Magento maintenance mode

You can ultimately enable Maintenance mode by putting the maintenance.flag file in the Magento root folder. The maintenance mode also changes the index.php file permission to 666, so this makes it unable to be executed by web browsers.

For this problem, please remove maintenance.flag file or run the following command:

Remove var/.maintenance.flag file. Also, you can run this below command from your ssh:

php bin/magento maintenance:disable

After that, you need to change the permission for index.php to 755 and please clear the cache to check whether this error is fixed or not.

7. Install CURL Extension

One of the errors that you often encounter is the missing CURL extension. This also causes Magento 500 Internal Server Error. The simplest way to solve this error is to install the CURL extension by running the following command:

yum install curl libcurl3 libcurl3-dev php5-curl

Finally, to confirm the changes, please restart httpd

Don’t forget to check again to know that the error is fixed.

8. Review Server Error Logs

Examine the log files to pinpoint the specific issue.

Addressing Apache Logs

To rectify errors related to missing server configurations or invalid commands in the server configuration, it’s essential to inspect the web server logs. For Apache, refer to the logs directory:

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

Directory List of Error Log

To determine the appropriate log file for debugging, you can utilize the Magento 2 Logger. Enable developer mode, reload the website, and analyze the error log located in the var/log directory of the Magento 2 store.

9. Fix the PHP Version Issue

Verify if your PHP version aligns with the server configuration. Examine the logs to determine the compatible version based on your requirements and install it accordingly. For updating the PHP version via SSH, use the following command:

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

10. Magento 2 All Commands

As a final troubleshooting step, if you’re still encountering the HTTP 500 Internal Server Error discussed in this article, you may attempt to resolve it by running the complete series of Magento 2 commands from your Magento root directory:

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

11. Fix Missing Extensions

Besides missing modules as we mentioned above, missing extensions in your PHP configuration or server can also be the cause of 500 server errors. What you need to do is figure out which one is missing right now and install it right away.

To fix the missing CURL extension by installing it, please run this command:

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

Final words

Overall, Magento 2 500 Internal Server Error is a common error that can happen in almost all websites, so don’t be too scared to face them. You just need to find the cause of that error and do one of the above solutions.

We hope this helpful article can help you to solve all the problems that you, unfortunately, encounter in your Magento store. You can also leave your comment or any question; our support team is always here to assist.

Thank you for reading!

Image Description
Hello, I'm the Chief Technology Officer of Mageplaza, and I am thrilled to share my story with you. My deep love and passion for technology have fueled my journey as a professional coder and an ultra-marathon runner. Over the past decade, I have accumulated extensive experience and honed my expertise in PHP development.
Website Support
& Maintenance Services

Make sure your store is not only in good shape but also thriving with a professional team yet at an affordable price.

Get Started
mageplaza services
x
    Subscribe

    Stay in the know

    Get special offers on the latest news from Mageplaza.

    Earn $10 in reward now!

    Earn $10 in reward now!

    comment
    iphone
    go up