What to do in case of a 500 error?

When you browse a website, your browser sends a request to the website’s server. The server processes the request and sends the files needed to display the page, along with the HTTP header and an HTTP status code.

The status code tells the browser the status of the request. For example, 200 indicates that everything is fine. If you get 500 as a return, it means that there was an error at the server level but that the server is not able to give more information about the origin of this error.

Error 500 is therefore a code signifying an internal error in the server, a contingency preventing it from responding to the request correctly.

When you encounter a 500 error, you must act quickly because your entire site is no longer functional.

error 500

How to identify the reasons for this 500 error?

The first question to ask yourself is “What action I have just did?” 

If you are working on your website and this error appears, it is most likely related to a change you have just made.

However, if you have not done anything, it may be due to an automatic update of a plugin for example, here are some tips to try to target where this error comes from.

 

Check your log files

On each of the hostings proposed by Netim, you will find an “error.log” file, accessible via FTP (See How to access your FTP directory).

Check the latest one for “Fatal error:” which will tell you what caused the 500 error in your hosting.

error.log
proxy-access.log

Check your .htaccess file

Once connected to your hosting’s FTP server, you will be able to see a file named “.htaccess” at the root of the “public_www” folder.

This file contains rewrite rules and specific configuration parameters.

Once you have identified this file, rename it to “.htaccess_old” so that it is no longer active.

If your site is working again, the problem is in the .htaccess file. You will have to open it and check line by line until you find the one that triggers the 500 error.

Check your PHP version

If you have just changed the PHP version associated with your hosting, this may be the cause of your 500 error.

During version upgrades, some features disappear and may cause this type of error.

You can also Change the PHP version associated with your hosting.

Check your code

If it is an error related to a syntax issue in your PHP code, the error type and corresponding line will be displayed on the 500 error page.

All you have to do is open the file in question, find the line and correct the problem.

CMS - Check your plugins

If you are using plugins, for example in WordPress, it is possible that one of them is causing this 500 error.

  1. Connect via FTP to the “public_www” folder
  2. Go to the “wp-content” 
  3. Change the name of the “plugins” folder to “plugins_old
  4. Test access to your site

If everything is working, it means that the error is coming from one of your plugins. To find out which one is:

  1. Change the name of the “plugins_old” folder to “plugins
  2. Go to “plugins” folder
  3. Modify all directories to ass “_old” to each
  4. Remove the “_old” from the first plugin
  5. Test your site

If it does not work, you have identified the problematic plugin.

If not, remove the “_old” from the next plugin and test again.

Do this until the end, as several plugins may be the source of your 500 error.

CMS - Check your database connection

If your CMS (WordPress, PrestaShop …) cannot connect to the database, it will display a 500 error.

This connection problem may simply be due to a change of password or a real unavailability of the latter (technical problem, blocking due to quotas being exceeded, etc.).

In the latter case, it is advisable to contact your host.

CMS - Check your cache system

If your CMS (WordPress, PrestaShop …) is equipped with a cache system, it can in some cases be the cause of this 500 error.

You will therefore need to “empty” your cache, either by using the functions associated with your plugin or, for example, by emptying the “public_www/var/cache/” folder if you are on PrestaShop.

Check the permissions on your folders and files

Incorrectly set permissions may result in a 500 error. Permissions are assigned as follows:

  • the first corresponds to the owner’s rights
  • the second corresponds to the rights of the group
  • the third number corresponds to the rights of other users

The following default permissions are recommended:

  • folders: 755
  • files: 644

Here is how to correct the permissions of a folder or file (here with the free FTP software FilleZilla):

  1. Open Filezilla and connect via FTP
  2. Locate the file or folder for which you want to change the permissions
  3. Right-click and select “File access rights…
  4. Set the permissions you wish to apply. Recursion can also be selected to apply these permissions to all child directories/files