How to Fix the 500 Internal Server Error in WordPress

Apr 12, 2018 | Errors and Troubleshooting

The 500 Internal Server error is arguably one of the most frustrating errors you can have. If you have it right now and you’re shaking your fist at the heavens shouting “why me?” don’t panic, that is a natural reaction! You’re not alone. This post will help you fix the error and get your website up and running again. Grab a coffee and we will walk you through the steps.

The Cause of the 500 Internal Server Error

This particular error can be caused by a range of issues and this is why fixing it is frustrating and time-consuming. It is worth noting that the internal server error is not specific to WordPress, and it can happen with any other application running on your server.
To troubleshoot the error we suggest starting with the following 3 common causes:

  • Corrupt .htaccess File.
  • PHP Memory Limit Exceeded
  • Faulty Plugin

Important!

Before proceeding further, please make a backup of your site. You do not want to lose all your hard work.

Fixing the Internal Server Error

Fixing a Corrupted .htaccess File

 
wordpress permalink
 
The first step in your effort to fix the internal server error should be to check for a corrupted .htaccess file. A .htaccess file can become corrupted when faulty syntax is written to the file.
If you have access to WP admin area:

  1. Login to your WordPress admin area.
  2. Go Settings -> Permalinks -> Select your preferred option and Save Changes.
  3. Refresh your site.

If you do not have access to WP admin area:

  1. Open your FTP client and access the root directory.
  2. Right click your .htaccess file and rename it to .htacess_old.
  3. Create a new .htaccess file and paste the Basic WP syntax from the WordPress Codex.
  4. Upload the new file and refresh your site.

If everything works a corrupted .htaccess file was the problem and it is now fixed.
If you do not see the .htaccess file, it could be hidden. If you are using FileZilla, click Server in the toolbar menu and then Force Showing Hidden Files.

Fixing the PHP Memory Limit Issue

The PHP memory limit is set by your hosting provider. Automatically, WordPress will try and increase the memory but it can only go as high as the hosting provider has allowed. On shared servers, this is typically set quite low.
To determine whether your application is exceeding the PHP memory limit, follow these steps.

Increase the PHP memory limit:

  1. Open your FTP client and access the root directory.
  2. Find the wp-config.php file and right click it and select Download.
  3. Open the file in a text editor and add or update the following: define(‘WP_MEMORY_LIMIT’, ‘128M’) accordingly.
  4. Save the file and re-upload it to your root directory.
  5. Refresh your site.

Please note that even if the site works, the root issue may still be present. Increasing the limit does not determine why your memory was exceeded in the first place. To ensure this error does not
happen again you may want to speak to your hosting provider or investigate further.
For now, enjoy having your site back up and running!

Fixing a Faulty/Incompatible Plugin

If neither of the above has fixed the error it could well be down to a plugin. Try these steps to fix the problem:
If you have access to WP admin area:

  1. Deactivate each plugin one by one and refresh the site each time locate the faulty plugin.
  2. Then, try and source a site friendly replacement. If you can’t live without this plugin, contact the developer directly and explain the problem as they may be able to provide a solution.

If you cannot open the WP admin area:

 

  1. Open your FTP client and access the root directory and navigate the wp-content folder.
  2. Rename the plugins folder to plugins_old. This will deactivate all the plugins on your site.
  3. Refresh the site. If the problem is gone it was caused by a faulty plugin.
  4. Reactivate each plugin one by one, refreshing your site as you do. Once the error returns you will have found the problematic plugin.

If none of these work it is time to try a new approach.

Further Measures to Fix the Internal Server Error

If you’re still having problems you can try the following measures to get your site back up and running.

Debugging

Using this feature to try and solve the problem is dependent on your knowledge of coding. That said, if you locate errors you may be able to use your good friend, Google, to find a solution, or you can pass on the information to your developer.

Debug your WordPress Site:

  1. Open your FTP client and access the root directory.
  2. Find the wp-config.php file and right click it and select Download.
  3. Open the file in a text editor and update it as per the example below.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Enable WP_DEBUG mode
define( ‘WP_DEBUG’, true );
 
// Enable Debug logging to the /wp-content/debug.log file
define( ‘WP_DEBUG_LOG’, true );
 
// Disable display of errors and warnings
define( ‘WP_DEBUG_DISPLAY’, false );
@ini_set( ‘display_errors’, 0 );
 
// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define( ‘SCRIPT_DEBUG’, true );
 

Save and upload the file. Refresh your site. Navigate to the wp-content directory with your FTP client and you will notice a debug.log file. Open it in a text editor and you will see a list of entries. You may have found the source of your 500 internal error.
The log file will list the issue and location where it occurs in your file system, but it is up to you to fix the faulty script.

Uploading a Fresh WordPress Install

This move is a bit drastic but if everything else has failed what have you got to lose?
Replacing Core Files to Fix the 500 Internal Error in 4 steps.

  1. Backup your site
  2. Download a fresh version of WordPress and extract the files
  3. Open your FTP client and upload the wp-admin and wp-includes from the fresh version of WordPress.
  4. Refresh your client and site.

Contacting your Host

Hosts often shrug off issues stating that the problem is in your file system and not on their servers. It is true that third party plugins do cause errors and this is why this measure should be taken after you can prove everything else has failed. Politely ask them to check their server logs to see if the issue is there.

 What is your Experience?

The 500 internal server error is a frustrating issue that doesn’t always have a clear cause or a clear solution.
Listed above were some of the tasks we would carry out when troubleshooting a website facing the problem. We hope that one of the solutions fixed it for you! If so, then please let us know in the comments below!