Fixing The Dreaded ‘Internal Server Error’ in WordPress (Step by Step)
- Last updated:
- 4 Comments
We’ve all been there — a site which was functioning perfectly well just seconds ago suddenly decides to throw a fit and spits out an internal server error. If you’re lucky, the WordPress admin still works, but, in some cases, even that may refuse to cooperate. In this article, we’ll explain what an internal server error is, and, more importantly, how to fix it.
Important: Always make a complete backup of your site (even if it’s not working as it should be) before making any changes — better safe than sorry!
Let’s get cracking.
What Is an Internal Server Error
Internal server errors are annoying to users and developers alike because they don’t provide any information about the root of the problem — they just tell you that there is one. Imagine you went to the doctor and said you felt pain, but refused to reveal where that pain was — it’d make it very hard for the doctor to treat it! That’s the difficulty with an internal server error — there’s no indication of where the problem’s coming from.
What’s more, the name ‘internal server error’ can be misleading, because, in almost all cases, your host (and/or server) isn’t to blame. If you take a look at the HTTP specifications, you can see that the 500 internal server error means the following:
The server encountered an unexpected condition that prevented it from fulfilling the request.
There’s nothing wrong with the server itself — it’s simply encountered something it can’t figure out. Let’s take a look at what that could be — and how you can get rid of it.
Step Zero: Enable Debugging
The first step should be to at least try to make sense of the error — you could get lucky! Depending on how your server handles errors, what you’re seeing may not actually be a server error at all. To see whether this is the case, you’ll need to edit the wp-config.php file in your website’s root directory. Download the file (via FTP), open it (using a text editor) and search for ‘WP_DEBUG’. If you find the line, simply change false to true and re-upload the file to the server.
If this line isn’t yet in your config file, create it using the following line of code:
define( "WP_DEBUG", true );
Reload your website and see if the error changes. If it does, and you now see a ‘fatal error’ message that points to a specific line of code in a specific file, then you’re looking at a relatively simple code error. Assuming said error originates from a plugin or theme, you’ll need to disable the offending product and/or work on fixing the issue yourself (or have someone else take a look at it if you’re not able to work out what’s happening on your own).
Note: after you’ve found the problem, remember to change the above mentioned ‘true’ value back to ‘false’ within the aforementioned wp-config file.
Step One: Check if Your Admin Works
Visit your website admin at
http://yoursite.com/wp-admin/. If this page loads properly and allows you to log in, you can be reasonably sure that the issue is with a plugin or with your theme. If your admin loads, continue to step two. If it doesn’t, skip to step four.
Step Two: Disable All Plugins
There’s almost no way a plugin can cause issues if it’s disabled, so, if you suspect one of your plugins is causing the problem, go to the plugins section and disable them all. This won’t delete them, and they’ll keep their saved data, but their code won’t be run. If you’ve disabled all your plugins and your site still won’t load, go to step three.
If your site’s up and running, start enabling your plugins one by one. Keep checking for that 500 internal server error after each plugin. When you’ve found the culprit, you can decide what to do with it. The best course of action is to keep the plugin disabled and notify the author immediately. If it’s a mission-critical plugin, you should probably look for a better, more stable alternative.
In some very rare cases, running old software such as PHP 5.3 may cause issues. Before replacing a plugin that’s proved to be trustworthy so far, take a look at step seven.
Step Three: Switch to a Default Theme
If deactivating your plugins didn’t solve the issue, it’s likely your theme’s the culprit. You can verify this easily by switching to a default WordPress theme. I recommend using Twenty Sixteen, which is the latest default theme. If switching to Twenty Sixteen solves the problem, you can re-enable all plugins and get to work finding the issue in your theme’s code.
If your theme’s from either the official theme repository or an independent theme shop, you should let the author know as soon as possible. If, on the other hand, it’s your own theme, you’ll need to get a developer to help you out, because these bugs can often be very difficult to find — even for seasoned coders.
In some very rare cases, running old software such as PHP 5.3 may cause issues. Before spending hours trying to find a bug, or paying hundreds of dollars to a developer, take a look at step seven.
Step Four: Increase Your Memory Limit
If your website’s using too much memory, it’ll definitely throw a fit — quite possibly resulting in a 500 internal server error. In many cases, this is a sign of a badly coded theme or plugin. It can be remedied quickly by increasing the memory limit, but this isn’t a sure-fire way of solving the problem, and won’t get to the root of it.
Either way, WooThemes has a short guide on increasing the WordPress memory limit. Keep in mind that your server or your account may have a set amount of memory allocated to it, though, and you won’t be able to increase your memory limit beyond that.
Alternatively, speak to your host for more specific instructions — some will be more than happy to increase your memory limit with almost no fuss on your part.
Step Five: Debug .htaccess Issues
The .htaccess file is a configuration file for your Apache Server that enables some relatively advanced functionality. Using it, you can enable gzip compression, change the maximum upload size and do all sorts of other handy things.
We’ve already written a guide on how to edit the .htaccess file, but it’s worth reiterating that this is a sensitive area where caution’s required. A typo, a forgotten space or an unclosed quote, for example, could easily cause a 500 internal server error, grinding your website — including your admin — to a halt.
The solution is to open your .htaccess file — it should be in the root WordPress folder — and see if there are any errors (especially if you’ve recently changed it). I recommend creating a backup named
backup.htaccess, then deleting the original
.htaccess file altogether to see if the website comes back online.
If it does, then the issue is with your .htaccess file. You can go through it line by line to see when your site goes down; once you’ve found the offending line make sure it doesn’t have any unnecessary text (perhaps an unclosed quote or something similar). If you can’t find the problem, I suggest deleting the line. Your website being completely down is far worse than a missing .htaccess line — ask around on forums if you need more help.
Step Six: Re-Install WordPress
It’s extremely rare, but you may have some corrupted files in the WordPress core. This isn’t anything to worry about — something may have gone wrong when your server was copying the required files, for example. Re-uploading the WordPress Core files may solve your problem.
Download a fresh copy of WordPress and use an FTP application to upload everything except the
wp-content folder. If you need more detailed instructions, take a look at the Codex article on Upgrading WordPress.
Step Seven: PHP Version Issues
While old PHP versions usually don’t cause 500 internal server errors, it may be worth talking to your host and asking them to give you a newer version before spending valuable time and money. PHP 7 has deprecated some previous features — for example, a plugin may use a function that’s not available in older version of PHP, and so on.
Ask your host what version of PHP you’re running. PHP 5.2 is now ten years old and 5.3 is seven years old — don’t accept it if your host is running your site on such old versions. You should at least have some variant of 5.4 running, or, better yet, the brand new PHP 7 (for optimum performance).
While it’s unlikely you’ll have two problems at once, it can happen. You may have a plugin that’s causing an issue, as well as an
.htaccess problem. In this case, the problem won’t be resolved when you disable all plugins and it won’t be resolved if you remove your
.htaccess file — only if you do both.
If you’ve followed these steps and you’re still getting a 500 internal server error, you should start again and make sure to not undo any changes. Keep your plugins disabled, keep your theme switched to Twenty Sixteen, and so on.
Because of the vagueness of the 500 internal server error message, resolving it can be difficult, but by following the steps above you should be able to figure out what’s going on.
If you still can’t solve the problem, contact your host. Link to this article and let them know you’ve tried these steps, as they’ll appreciate the effort and will be able to locate the issue a lot faster!
Seen any edge cases or downright weird things happening in relation to this error? Let us know in the comments!