How to fix a 500 error in Magento 2

Reading Time: 4 minutes

How many times have we encountered a 500 error? In fact, it happens very often to find yourself on a web page that is unreachable due to an error, Internal Server Error, precisely the error 500.

What is the 500 error?

In fact in practice what does this error refer to?

In fact, we know that when you visit a site, the browser on which we are browsing the site communicates with the server on which the site we are trying to reach is located. The server in turn then processes the request and returns the requested content. During this phase, however, two situations can arise:

  1. Code 200 -> this means that the process was successful and that in essence, everything is fine.
  2. Code 500 -> this means that there is an error in progress, related to the server.

Basically with a 500 error, it’s nothing more than code indicating that the server has found a problematic situation and is not allowing it to process the request.

There are many types of errors, for example all codes of the 4XX type, are related to page breaks, while those of the 5XX series are related to the server.

Why is it important to resolve error 500?

Not to mention that obviously a blank page, or one containing an error, is never pleasant. Who lands on a page of our site and sees that it is not reachable, certainly has a negative response towards us. And if it is an E-Commerce site, the result is that the potential customer leaves our site and buys elsewhere.

Furthermore, can this error also cause other problems?

Error 500, does it penalize SEO?

Yes, because it can negatively affect SEO if it is not resolved in time. In fact, if the site is down for only a few minutes, nothing happens, but if it has been down for hours, Google encounters a problem on the site. This factor can then affect your ranking, penalizing your site. It is therefore necessary to understand, especially if the problem repeats itself with a certain frequency, know what depends and solve it as soon as possible.

What can the error 500 depend on?

The factors related to this situation can be many, but in essence, this error is shown when the server is unable to communicate correctly with the browser and therefore show the web page we are trying to reach. The causes may depend primarily on a specific problem with the hosting machine, for which it is obviously necessary to contact our provider. But there can also be errors related to unsuitable hosting, with inadequate resources, incompatibility of plugins or themes, error in permissions etc.

However regardless of the causes that determine this error, if you have chosen a good provider, you will surely have a good service and support that can help you in this.

How to fix the error 500?

First of all, to avoid the occurrence or in any case limit this error, you need to buy a good hosting . However, sometimes even having great hosting is not enough. So what to do? There are some simple and less simple operations we can try to do to try to solve.

Basically, the error could be caused by both the user and the server. Let’s see a roundup of possible solutions, linked to both situations.

Reload the page

The first thing that comes to mind, as soon as we are faced with a 500 error, is to reload the page. Just wait a minute and then try again. It may seem trivial, but it is often one of the most effective solutions, when it comes to minor momentary problems. Sometimes it happens that the host or the server are momentarily overloaded, but after that moment, everything returns to normal.

Clear the Cache

Another easy operation to do, before embarking on more winding roads, is to clear the browser cache. This is an operation that allows you to solve the problem quickly and easily.

Error connecting to the database

Sometimes 500 errors can depend on a database connection error. Typically when this occurs, the page appears completely blank, because the data cannot be retrieved, as there is a connection problem. This can be due to errors in the database credentials, or corruption errors in the database itself or in the CMS, or due to problems with the database server.

Error related to permissions

Incorrectly configured permissions are one of the most common reasons for Magento server error 500. To fix this, you need to update the permissions settings on the root folder using these commands:

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

Or you can use the Magento Cleanup utility (https://example.com/magento/magento-cleanup.php) to automatically set the correct permissions.

For more information on system permissions, see the official documentation .

Memory limitation

PHP memory limit is another popular reason that leads to error 500 in Magento 2 after data update. In this case, you just need to increase the volume.

If you have access to change the server settings, go to the php.ini file and add:

memory_limit = 756M

756M is the minimum value to set a larger memory volume.

Otherwise, add this code to the .htaccess file:

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

Problems in the .htaccess file

Usually, problems with the .htaccess file occur when trying to install some components, such as themes, plug-ins, patches, etc. If you encounter any configuration errors, you can see the 500 error on the Magento website.

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

Missing forms

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

Problem with third party plug-in

Sometimes it may happen that after installing a theme or extension, this type of error may occur. It can happen for example on incorrectly configured hosts, which cause a temporary timeout to occur immediately after the update. By updating the page, however, everything should be resolved.

If not, perhaps we are facing a problem of incompatibility of themes and extensions. So what we recommend is:

  • Only install items that are compatible with your version of the CMS
  • If you need to install multiple elements, install them one at a time in order to check the compatibility of each individual element
  • Make a backup before each update

As this error in Magento can occur after implementing a new plugin or updates, use the following command php bin / magento mod: disable to deactivate the mod and contact your vendor as soon as possible.

Technical errors create a small problem in case you buy extensions from a premier extension builder. To sell products on the Magento market and be certified by the experts, it is necessary to adapt the internal code standards to Magento and meet all the compatibility requirements.

 

Andrea SaccĂ 
FOUNDER Bhoost Hosting

Sharing tips and insights on Bhoost and Page Speed Optimization

Leave a Reply

Your email address will not be published.