There are currently 74,000 support requests on WordPress.org for “how to fix 500 Internal Server Error.” Let’s just say it’s a huge problem for people everyday.
If you are a user of WordPress then chances are you’ve come across a “500 Internal Server Error” at some time or another. This server status code basically is telling the user: “Something is wrong with the server itself.”
Personally I am inflicted with a 500 Internal Server Error at least once per week. It might be a new client that came to us, a developer that messed something up, or just an innocent mistake that came about innocently.
The 500 Internal Server Error is kind of a cop out for servers. It is the error that the server spits out when it isn’t sure what is wrong.
Before we get started, and as with any major work always backup your WordPress website completely. This includes both the file, and the database. Now that you’ve done that I will list the most popular reasons why a server with WordPress installed might issue a “500 Internal Server Error” and how you can fix it.
A corrupted WordPress theme
There could be a 1000 different ways that your theme is corrupted. A corrupted theme could easily cause a 500 Internal Server Error and ruin your day. The key with this issue is to rule it out. If you can identify that the theme is the issue, we know that it probably isn’t something else.
Solution: Disable your theme temporarily by renaming it in FTP. Once disabled, check to see if the site is working again. If it is you can rule out any other issues and fix whatever is broken within your theme. One way to check is to re-download your theme from the developer and see if any files have become corrupted. Contact your theme developer for more info.
A corrupted plugin
Plugins can cause nightmares when working with WordPress but even worse they can cause 500 Internal Server Errors. Just like a corrupted theme, the key is to rule out that you have a bad plugin.
Solution: Disable each plugin, testing your website after disabling each one. Using the process of elimination you can determine which plugin is the culprit.
A corrupted WordPress install
There is a chance one of your WordPress core files went awry. If this happens you are totally screwed. Ok just kidding, it’s not that difficult. If you are actively working on your website, sometimes you might accidentally delete a necessary file, accidentally modify it, or accidentally change the permissions. Any of the above could cause a 500 internal server error and ruin your lunch.
Solution: Reinstall WordPress like so:
- grab a coffee
- backup everything
- download a copy of the latest version of WordPress to your computer
- deactivate all plugins just to be sure
- unzip / unpack WordPress on your computer
- take a deep breath
- using FTP, upload and overwrite your current version of WordPress
- re-upload the backup of wpconfig.php
- test to see if the 500 internal server error is gone
A corrupted .htaccess file
The .htaccess file is your server configuration file. It can do everything from redirects, to rewrites to directory passwords. Treat it well, and it will give you tons of configuration options. Abuse it, and it will spit out a 500 Internal Server Error.
Solution: Rename your .htaccess file and replace with a clean version. You can download a safe and default .htaccess file for WordPress here.
Not enough server memory
Just like any computer program, WordPress needs enough memory in order to run properly. If WordPress doesn’t have enough memory it will issue a 500 Internal Server Error.
Solution: try one, some or all of the following:
in your wp-config.php file:
in your php.ini file:
memory_limit = 64M ; Maximum amount of memory a script may consume (64MB)
in your .htaccess file:
php_value memory_limit 64M
Improper file ownership
In Linux, all files and folders are owned by users and groups. If your WordPress files and folders are owned by the wrong user or group, you are going to get slammed with a 500 Internal Server Error or worse.
Solution: This problem can vary from install to install. While there may be a number of different solutions, something along the lines of this should work:
chown -R $user. /path/to/public/html/*
Essentially you are saying “change the ownership of these files and directories to this user.” Of course, make sure you are changing the ownership to the correct user.
Improper file permissions
This one can really get nasty. In Linux, all files and folders are marked with different permissions, mainly: read, write and execute. There are countless combinations of permissions, and even more ways to screw this up if you don’t know what you are doing. Even worse then getting a 500 Internal Server Error in WordPress, if you don’t have your permission game on point expect for your server to get pwned.
Solution: If you don’t know your way around a Linux filesystem, this isn’t going to be easy. My advice is to follow WordPress’s guide to file permissions and check each file to make sure you aren’t blocking or allowing access.
Remember, some hosts have special requirements. For instance one server says:
all folders in home directory must be set to 644 permissions and all files should be set to 755 due to the fact that our server is run in a suPHP environment.
Check with your hosting provider for more information.
Out of resources on your hosting provider
I have only seen this happen 1 time in the last 10 years, but it is always a possibility. If you run out of hard disk space on your hosting provider (or RAM/maybe CPU) you may get a 500 Internal Server Error.
WordPress needs hard disk space, ram and CPU to run just like any other program. If you run out it is going to throw a hissy-fit.
Solution: Check with your hosting provider to see what your load is looking like. If need be, buy more disk space or upgrade your hosting package. If you are hitting these limits, it is probably time to upgrade anyway.
Errors in error log
We recently came across a WordPress install with a 500 Internal Server Error that had 100’s of megs in the error log. One particular error read something along the lines of:
PHP Fatal error: Call to undefined function curl_init() in /var/www/eg/wp-content/plugins/ajax-for-all/inc/admin.php on line 100
With a little research and a good attitude, we quickly found out that we were missing “php5-curl library.” All we had to do was install that library, restart and wham, no more error.
Solution: It depends based on the error. Sometimes you’ll have to install something that is missing, other times you’ll have to really do some digging.
Other possibilities / solutions
There are a number of other tips if you are looking to whittle down the reason why you are getting a 500 Internal Server Error on WordPress:
- have you upgraded downgrade your MySQL / PHP / Linux distro?
- have you checked your PHP error log?
- have you checked other error logs?
- worst case scenario you can restart Apache / MySQL server
- is your server plugged in?
Has this ever happened to you?
If so give me a shout below in the comments, or on Twitter.