How To Fix the 500 Internal Server Error in WordPress

  • How Tos

All is going fine and one day it happens. The infamous HTTP 500 internal server error in WordPress arrives to spoil the party. The HTTP 500 internal server error is a server-side issue and not a client-side one. Something has malfunctioned on the server side. Finding the root cause is tricky, as this internal server error for WordPress can be caused by multiple issues. So, the way to fix the WordPress 500 internal server error is to tackle all the major causes one by one and see if any one of them solves the issue.

WordPress 500 Internal Server Error Explained

The 500 internal server error will always prevent the site from loading. The issue is with the web server, where something has gone haywire. The users will be presented with a page that shows an error code. It would not mention what has gone wrong, only the error code. It is now up to the site admins to figure out what is causing the issue. The most common message that is displayed is – “The page cannot be displayed because an internal server error has occurred”.

The 500 internal server error can present itself in different ways- but it all means the same thing. It is a generic error code. The various variations are:

  • 500 error
  • 500 Internal Server Error
  • HTTP 500
  • HTTP 500 Internal Server Error
  • The website cannot display the page- HTTP 500
  • 500- Internal Server Error
  • Internal Server Error

The Top Reasons for WordPress 500 Internal Server Error

The common causes of WordPress 500 internal server error are:

  • Corrupt .htaccess file
  • Plugin issues
  • Theme issues
  • PHP memory limit issues
  • Database Connection Error
  • Corrupt WordPress core files
  • PHP Version
  • Permission Issue
  • Web Host issues

The 500 internal server error can negatively impact the SEO. With the website down for a long time, the search engine crawlers will interpret it as a website issue and the ranking would be affected if Google can’t access the website. So, it is vital to get the website up and running as fast as possible.

How to Fix WordPress 500 Internal Server Error

Now that we have seen the various reasons behind this error, let us move into the solution part.

We can use the WordPress debugging tool to help us in these kinds of situations. The debug option is not on by default, so first, we have to enable it. Locate the wp-config.php file with the help of SSH or FTP. You can also use file management plugins to find and edit the wp-config.php file. Examples are Advanced File Manager and File Manager. Open the file and add the below code snippet.

define( 'WP_DEBUG', true ); 
define( 'WP_DEBUG_LOG', true ); 
define( 'WP_DEBUG_DISPLAY', false );

Once done, reload the site and see if the error message displays any more information or it will create a debug.log file, which can be found inside the wp-content directory. Once the debugging is finished change the value of WP_DEBUG to false. Now, to make sense of the log file, one might need strong technical knowledge. So having a developer look at the log file is always suggested.

It is also a good idea to check the error.log file. Depending on the host, the error log file location would change. The error log section would indicate what might be causing the 500 internal server error. The more information we have on the problem, the better it is.

Based on the information received from the debugging and the error log file, we can move forward to fix the issues. How to fix the most common causes for the 500 internal server error for WordPress are mentioned below:

1. Fix the .htaccess File

Sometimes a corrupted .htaccess file can throw a WordPress 500 internal server error. We can either check this by deactivating the current .htaccess file and create a new one using an FTP client. The .htaccess file is located inside the root folder.

Firstly disable it by renaming it. For example, rename it to .htaccess_old. Create a new file and choose edit. Then paste the standard WordPress .htaccess code and save the file.

# BEGIN WordPress

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Save the file under the name .htaccess. Try loading the website again and see if it fixed the issue. If you do not see the .htaccess file, enable show hidden files from the file manager options. One can also use an old working .htaccess file from a previous backup and check if it fixes the issue.

2. Find the Incompatible Plugin

This step can get a bit longer depending on the number of plugins you have installed. If the issue surfaced immediately after the installation of a new plugin, then we already know who the culprit is. But if not, deactivating all the plugins and testing them one by one is the way to go. If you can still access the WordPress dashboard disable all the plugins from there. If not go with an FTP file manager.

With the help of an FTP file manager, open the wp-content folder and locate the plugins folder. Rename the plugin folder and try reloading the website.

If it fixes the issue, then the plugins were causing the issue. Now, to find out the plugin which was causing the error, rename the plugin folder to the default name and start renaming the installed plugins folder to a different one. Once the troublesome plugin has been identified, rename it and refresh the site. The site would be back to normal now if the root cause was a bad plugin.

3. Change the Theme

Just like plugins, a new theme or an update to the existing theme can cause the 500 internal server error. If the WordPress dashboard is accessible, change the theme from there. If not, do it from an FTP file manager. Locate the themes folder, and rename the current theme folder to a different one like currenttheme_old.

Doing this will only result in a white screen and won’t load any of your content but will give you access back to wp-admin. If it does, then you know that the changes made to the theme caused the issue.

4. Increase the PHP Memory Limit

The PHP memory limit issue can also cause a 500 internal server error that affects WordPress sites. The PHP limit can be changed in multiple ways and also depends on the host. If you are using the cPanel then changing the PHP memory limit is easy.

From the cPanel, select MultiPHP INI Editor

Choose Basic Mode

Now, select the location for the domain

Once the correct domain has been selected, look for the memory_limit section and change the value and click Apply.

We can also change the memory limit through an FTP file manager. Open the wp-config.php file and add the line:

define('WP_MEMORY_LIMIT', 'mmM'); 
increase memory limit to solve 500 internal server error

Here “mm” stands for the new value to be added. Most often 256M is sufficient. We can also increase the PHP limit through the php.ini file. The php.ini file can be found in the root directory, if not create one. Then add the following code:

memory_limit = mmM

We can also add the code to the .htaccess file. Add the following code after #END WordPress.

 php_value memory_limit mmM

This is how the end result should look like.

# BEGIN WordPress

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress
php_value memory_limit mmM

This is only a temporary solution, as we will need to find out what is causing the memory overuse.

5. Check for Database Connection Error

A database connection error can also throw a 500 internal server error. If it is caused by a database connection error, then the site will be inaccessible to the visitors and we can’t access the WordPress dashboard also. Most often this is caused due to incorrect login credentials, and a corrupted WordPress database.

Make sure the database credentials inside the wp-config file and credentials in the Database panel are the same. If not, rectify it.

confirm WordPress database credentials

Things to look for are Database Name, MySQL database username, MySQL database password, and MySQL hostname. Now, moving on to the database corruption part, it can be fixed from phpMyAdmin. Select the database and hit repair.

6. Recheck Corrupt WordPress Core Files

The 500 internal server error can also be caused by corrupted core files. Then downloading and uploading the latest WordPress is the best solution. After downloading and extracting the WordPress zip file, delete the wp-content folder and upload the wp-admin and wp-includes folders and the rest of the files through an FTP file manager and choose to overwrite when asked.

7. Solve PHP Version Issues

PHP version can also lead to the WordPress 500 internal server error. PHP version can cause compatibility issues with certain plugins, as they need a specific version to work properly. Changing the PHP version would depend on the hosting service provider.

 For cPanel users, to change the version, navigate to MultiPHP Manager

Then select the domain and choose the PHP version and click apply.

8. Check and Correct Permission Issues

Wrong permission rules for files and directories can also lead to the WordPress website showing 500 internal server error. The directories should have either 755 or 750 and all the files should have 644 or 640 as the numeric value and also -rw-r-r-. The directories should be 755 and drwxr-xr-x. The wp-config should be set to 440 or 400 for security reasons.

9. Contact the Web Host

If all the above-mentioned steps fail and don’t solve the issue, then the web host is the only way. This issue could be caused by a problem from the host itself. In such scenarios, notifying them about the issue is important. Even if it is not, their expertise can help us solve the issue at a rapid pace.

Wrapping Up

Finding the root cause of the WordPress 500 internal server error is tricky and can consume some time. The above-mentioned ones are the most common causes of this error. Sometimes the error may result from a mistake from the web host itself. So, contacting the web host is also helpful if none of the other mentioned methods works to solve the issue.

The WP Week Newsletter

A weekly newsletter covering updates from the WordPress ecosystem that are relevant and helpful for WordPress agencies, developers, and enthusiasts

Leave your comment

Your email address will not be published. Required fields are marked *