Menu Close

How to Fix the WordPress 500 Internal Server Error


Most of us, either developers, designers or even end users have had to endure at least one in our lifetime. That is, the painful process of getting an Internal server error and trying to fix it. Many people don’t care to know more – they just want to fix it. But if you do not try to at least understand it, you’re bound to suffer this fate more often. The 500 internal server error is very important since it completely stops all processes and can bring your entire site down. So if we ever want to get rid of it we need to better understand what it means first.

In this article I’m going to cover the basics of what this error means, how can you identify the problem and of course, how to fix it. But before getting started I want to walk you through the various http (site) errors that exist and what they could potentially mean. If you prefer you can skip down to how to fix your WordPress 500 error.

Common HTTP Status and Error Codes

First things first – I’m going to explain what these errors really mean. There is currently a list of status and errors for HTTP that can be accessed to better troubleshoot a situation. These errors are usually divided in types. So, to cut this matter short, we’ll cover the most important errors and informational status codes you will find while working with your WordPress site.

100x Response (Status)

This type of response is given directly by the webserver. Depending on your hosting company, the response can be given by either Apache, nginx or any other webserver that the company uses. This type of response is not associated with errors. They are generally used to indicate that a connection is in place. They are status response codes to connections.

200x Response (Success)

The successful ones is what I call them. This type of response always indicates a success. It means that either the server has successfully made the connection to you, that the resources asked were given correctly or that a proxy connection has been made.

The most common successful code is known as the 200 OK. You can see examples of this if you’re using a WordPress speed test tool, say on Pingdom Tools and you’re trying to find out the FTTB (First time to byte). The 200 OK response is always given to the first request made.

300x Response (Redirections)

The redirection guys. These codes are always referred if the given link is going into a redirection. 300 status codes indicate a successful redirection and is also, not considered an error.

Say you have an SSL (HTTPS) site and you also have direct access to HTTP (non-secured) and you want to redirect everyone to the HTTPS version of your site. You could create a redirection for all requests coming from HTTP to go to HTTPS. If you accidentally try to enter your site by HTTP your browser will receive a 300 response indicating a redirection to the HTTPS version.

Simple WooCommerce Tips: Yoast SEO Redirects for Out of Stock Products

Another common example you might be familiar with is onsite redirections for SEO. Perhaps you’ve removed old posts or pages. With the help of a plugin such as Yoast SEO you can 301 redirect these to newer, more relevant pages. Or use a 307 temporary redirect if you’re working on an update and want to direct users to a different page for a bit.

400x Response (Client Errors)

The famous client errors. These types of errors involve problems in your browser. Typically, it is unable to load a certain asset (the most commonly known is the 404 error). These are error codes that are not considered to be severe.

The same error could be shown if you try to access a non-existent image on your site. For example, you may want to use a 410 redirect to tell search engines that content has been permanently removed, or a 451 if you’ve made a page unavailable for legal reasons (such as a DMCA request).

500x Response (Server Errors)

And now we have reached our main protagonist. The 500 errors. As you can see, these are important errors and are always related to the server itself. Server errors are important because they can effectively crash your website. Of these errors, the most important are:

  • A 503 Service unavailable
  • A 502 bad gateway error
  • A 500 internal server error

Let’s explore the 3 of them by order of importance.

503 Service Unavailable

The least serious is the 503 service unavailable. If this error shows up you have a resource problem on the webserver. Almost all the time it shows up when your server is overloaded. In plain terms, if you see this error, know that it is temporary and it is directly related to too much traffic and this is overloading the CPU. Whenever the CPU and the webserver itself can’t process more incoming connections because it has reached a 100% CPU utilization, you will see this error popup.

You can fix this is by either switching to a better webserver (from Apache to Nginx for example) or by implementing a WordPress caching plugin on your site.

502 Bad Gateway

This is what I called the misconfiguration error. This error does not show up for no reason. If you ever have this error, the most probably cause is that you did something and you did it wrong. This happens usually when folks attempt to tweak Apache and PHP configuration or when trying to optimize nginx. The bad gateway is an error that almost always happens when the PHP FPM (Fast Process Manager) loses connection. Either from tweaking the wrong settings or because the process crashed. This leads the webserver to respond with a bad gateway.

The easiest way to fix this error is to double check your PHP-FPM configuration as that is the most probable cause for this error. This happens more often on the Nginx side than on Apache and almost never happens on hosting services provided by cPanel or Plesk. Those last two panels have safeguards in place to prevent a misconfiguration error. But, it does happen very often when managing your own VPS.

Looking for more help with this one? Follow our guide on how to fix a 502 bad gateway error.

500 Internal Server Error

The big bad boy of errors. The 500 internal server error is the worse of them all, primarily because is such a general error. If you don’t have sufficient knowledge on how to deal with it, it can be a real pain as it can bring your entire site down. The 502 bad gateway error also throws your site down but it’s easier to diagnose and fix. As mentioned, it is almost always related to the FPM configuration.

Reasons for a 500 Internal Server Error & How to Fix Them

The first thing to understand about a 500 error is that it can be caused by a number of different factors that are almost always related to failures in code execution. Instead of trying to diagnose everything at once, I’ll give you a list of errors by type of problem and what you were doing.

  • By migrating an older site to a newer hosting
  • An error in the .htaccess in an apache configuration
  • An error in PHP code execution

There are other less common cases that can throw a 500 internal server error but for the sake of simplicity and usability of this article I’m going to focus on these three.

1. Migrating an Older Site to Newer Hosting

There are several ways in which this error can show up but almost always seems related to the PHP version that is bound to your webserver. Newer PHP versions can generate an immediate 500 internal server error if the current site or plugins do not support the current version.

This error is classic for example, when you migrate your site from a mediocre hosting with an older PHP version to a newer hosting that only accept the newer versions (7.0 and up). If your site was not updated recently, an old plugin may be causing an issue. I call this the “migration internal server error” because it almost always happens when you migrate a site.


The best way to fix this terrible error when you’re trying so hard to migrate your WordPress site to new hosting is to make a complete copy of your plugins and the theme of your site. After doing this, please, delete all the plugins from your site and try again. If the error goes away, it is almost guaranteed that the error was generated by a newer version of PHP on your hosting that just simply refuses to execute code on your older plugin. By re-uploading one plugin at a time you can easily find out which was the one causing the issue.

This errors are almost always presenting themselves when migrating older sites running on PHP 5.4 and 5.6 to a newer hosting with PHP 7.0, 7.1 or 7.2.

The same thing applies to your theme. Since themes can and do implement extra PHP code in the functions.php, single and page.php files. It is most probably that an older theme without updates can break your site once migrated to a hosting with a newer version of PHP, this situation is unfortunate as the only way of fixing this is to change the theme and rebuild your site. This is the worse case scenario.

2. .htaccess Apache Configuration Error

Let’s say you were configuring a plugin and suddenly everything crashes. If you get a 500 internal server error while configuring, for example a caching plugin or any plugin related to optimizations, you need to check if the plugin added extra code to your .htaccess file.

Since apache can be modified in realtime by configuring the functions in the .htaccess file (which is almost always hidden) a bad configuration can break your site.


The way to fix it is by either accessing your site through FTP and modifying your .htaccess file or by direct editing, say with the file explorer on cPanel or Plesk.

If you don’t know how to revert what the plugin has made and you need your site up again, make a copy of the existing contents as text file. Save this as your backup. Then replace the entire .htaccess with the following code:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

This is the default WordPress .htaccess file. It should work with any site.  So, if you’re desperate and don’t know which part to remove, just remove everything and paste this code .It will save you instantly. You can later remove the plugin or try to configure it again. You now know a way to save you from this catastrophic error. At least if it’s .htaccess related.

If you don’t know if it’s .htaccess related, or this error started showing up without you touching any plugins, play it safe. Just copy the contents of your .htaccess and copy the code above to try and diagnose. If this does not fix it, leave .htaccess as it is and then try the next suggestion.

3. PHP Code Execution Error

These types of errors are more common than you think and they usually happen if a plugin is executing invalid code. The most common way of executing invalid code is when you try to execute deprecated instructions. Perhaps you’re trying to run an old plugin that was only designed to work with up to PHP 5.4 or 5.6 with PHP 7.0 or newer versions. Deprecated and invalid functions will create an internal server error that can only be diagnosed by enabling WP Debug mode.

Enable wp_debug

The WordPress debug mode will give you extensive details about the error that was thrown that stopped execution. The way we enable it is by changing the value from “false” to “true” on wp_debug inside the file wp-config.php on the root folder of your site.

If you’re using Plesk or cPanel you can do so by simply changing that value using the File Explorer and editing wp-config.php. You can also follow this debugging guide by Blogvault for more detailed steps.

Once the file has been edited you will be able to see the actual error being generated that stopped execution. The error will also state the path and file where this happened, so it’s easy to guess what plugin caused it. By disabling it we can skip the error and later update the plugin or remove it, depending on the situation.


The vast majority of instances of an 500 internal server error involves older theme versions or plugins. By switching your theme to any standard WP theme you will be able to regain access to your site. Disabling the conflicting plugins will also return your access to the dashboard. If you happen to encounter a situation in which your theme is the one responsible for breaking the site, the best way to fix it is by creating a zip file of said theme from the theme folder wp-content/themes/yourtheme then deleting it from your site. This will remove the error so you can regain access to your site. You can then re-upload it and update it without activating it. You can do the same thing with plugins.

The most common situations for a 500 internal server errors can be fixed by updating. In cases where the said plugin/theme does not have an update available you can try switching to an older PHP version. But know that this is a short-lived workaround. Newer versions of PHP become stable and older versions are deprecated regularly. Sooner or later your site will definitely stop working. The best approach will always be to update or remove/replace the plugins in question.

Always remember, it is better to prevent and update than trying to do damage control later.

Wrapping Up Our Guide to WordPress 500 Internal Server Errors

A WordPress 500 internal server error can be a real pain. But in most cases, they can be easily diagnosed and fixed by simply removing/updating the conflicting parts of your site. Although there can be situations where these errors present themselves outside of the norm (for example when you’re developing a plugin), that goes beyond of the purpose of this article.

For the vast majority of people, following the above advice should fix your problem. Remember that wp-debug is your best friend and always follow the steps carefully. You will have your site back online in no time.

Have any other questions? Or tips for dealing with a WordPress 500 internal server error? Let me know!

View Source
Posted in WordPress