500 Internal Server Error
If you just installed WordPress, a WordPress plugin, or a theme for your site, and out of nowhere your site returns a 500 Internal Server Error, please read on. If you have been surfing the web for any length of time, you have probably encountered a 500 internal server error. These errors are not confined to WordPress. They are generic errors that report very little on what the actual cause is. First, don't panic. Lots of people have been confronted with these errors, and they can be fixed.
There are five major reasons why these errors occur in WordPress:
- An incorrect web server configuration
- Incorrect folder/file permissions
- Corrupt files or files that contain errors in code
- PHP memory limits set too low
- Conflicting third-party plugins
1. Incorrect web server configuration
If your web server (whether it be Apache or IIS) is configured with incorrect directives, it can cause 500 errors to occur. The problem is that web hosting support will often blame the error on the software you have installed without even checking to see what is contained in their error logs. Just know that after you have checked the following remaining causes, and they fail to resolve the issue, you will need to (sometimes forcefully) get your web host to help diagnose and fix the problem.
2. Incorrect file permissions
With very few exceptions, file permission for WordPress, plugins, and themes need to be set at 755 for folders, and 644 for files. You may think that setting permissions more loosely, like 777, will relieve the problem, but you would be wrong. Setting permissions either too strict or too loose often causes this and other errors.
3. Corrupt files or files that contain errors in code
By far the most common 500 error produced by a file is related to the WordPress .htaccess file. The .htaccess file is primarily designed to be used with custom permalink structures. But it is also used by some third-party plugins, and for overriding certain server configuration directives if allowed. If it contains errors, it can return the dreaded 500 internal server error. The .htaccess file is located in the root folder of your WordPress installation (not the theme).
- Log into your site via FTP (Filezilla, etc.).
- Download a copy of your .htaccess file and rename the copy e.g. ".htaccess-backup".
- Delete the .htaccess file residing on your Web server.
- Create a new blank file called ".htaccess" on your PC/laptop/Mac.
- Upload this new file to your Web server in the same place as the original .htaccess (which you deleted).
- Navigate to your WordPress admin URL, e.g. http://www.yoursite.com/wordpress/wp-admin, and you should now be able to log in.
- Finally, once logged in, navigate to the Permalinks settings page in the admin console and do nothing further. Simply going to the settings page should enable WordPress to write the correct .htaccess declarations itself. You should now be able to navigate to www.yoursite.com or http://www.yoursite.com/wordpress (depending on whether WordPress is running your entire site or just a blog etc.) and all should be well once more.
4. PHP memory limits are set too low, There are two ways to solve this problem.
- You can either get your web host to increase your PHP limits.
5. Conflicting Third Party Plugins Should Be Deactivated
- If you can access the admin area of your site, log in to your admin section and deactivate all plugins. After doing so, check your front-end page again. If it loads without error, you have a plugin conflict. Now, start activating each plugin one by one. When you see the 500 error again on the front-end pages, you will know that the last plugin you activated is the likely culprit. Deactivate it and continue checking all remaining plugins one by one to make sure there are no others.
- If you are getting the 500 error on the front end and the back end admin area, then you will need to access your site via an FTP client. A little-known trick is to change the name of your /wp-content/plugins folder to something else temporarily like "plugins.bak." This will make WordPress ignore your plugins. Then check to see if this resolves the problem. If it does, log into your admin section and then change your plugin.bak folder back to plugins. Then deactivate all of your plugins via your admin page.
Recommended PHP configuration limits are as follows:
- max_execution_time 180
- memory_limit 128M
- post_max_size 32M
- upload_max_filesize 32M
How To Verify Your Current PHP Limits
You can verify your PHP configuration limits by installing a simple plugin found here. In addition, you can always contact your host and ask them what the current settings are and have them adjust them if needed. Please note though that many hosts will try to keep the PHP limits low without reason. However you are paying for it, and therefore should be getting your money's worth.