How to Fix a 500 Internal Server Error on a WordPress-Hosted Site
A tutorial on how to diagnose 500 internal server errors on a WordPress-hosted site and how to fix these errors in WordPress sites.
Join the DZone community and get the full member experience.Join For Free
The 500 Internal Server Error is a very general HTTP status code that means something has gone wrong on a website’s server, but the server does not get any more specific on what the actual problem is.
Websites phrase 500 errors in many ways, but they’re all basically saying the same thing: there’s a general server issue going on right now.
Most of the time there isn’t anything you can do but contact the website directly and then wait on them to fix it.
On the off chance there is a problem on your end, try clearing the cache and deleting any cookies from the site with the error.
Different Views of the 500 Server Error
The error message might be seen in any number of ways because each website is allowed to customize the message.
Here are several common ways that you might see the HTTP 500 error:
- 500 Internal Server Error
- HTTP 500 – Internal Server Error
- Temporary Error (500)
- Internal Server Error
- HTTP 500 Internal Error
- 500 Error
- HTTP Error 500
Since a 500 Internal Server Error is generated by the website you’re visiting, you could see one in any browser in any operating system, even on your smartphone.
Most of the time, it displays inside the browser window, just as web pages do.
Cause of 500 Server Error
- Browser Cache.
- Incorrect database login credentials.
- Corrupted database.
- Corrupted files in your WordPress installation.
- Issues with your database server.
- Corrupted WordPress core files.
- Corrupted .htaccess file and PHP memory limit.
- Issues with third-party plugins and themes.
- PHP timing out or fatal PHP errors with third-party plugins.
- Wrong file and folder permissions.
- Exhausted PHP memory limit on your server
- Corrupted or broken .htaccess file.
- Errors in CGI and Perl script.
Like we mentioned above, Internal Server Error messages indicate that something, in general, is wrong.
Most of the time, “wrong” means an issue with the page or site’s programming, but there’s certainly a chance that the problem is on your end.
To check if the problem is from your end do the following:
- Reload the web page. You can do that by selecting the refresh/reload button, pressing F5 or Ctrl+R, or trying the URL again from the address bar.
- Even if the 500 Internal Server Error is a problem on the web server, the issue might just be temporary. Trying the page again will often be successful.
- If the message appears during the checkout process at an online store, be aware that duplicate attempts to checkout may end up creating multiple orders— and multiple charges! Most merchants have automatic protections from these kinds of actions, but it’s still something to keep in mind.
- Clear your browser’s cache. If there’s a problem with the cached version of the page you’re viewing, it could be causing HTTP 500 issues.
- Internal Server Errors are not often caused by caching issues, but we have, on occasion, seen the error go away after clearing the cache. It’s such an easy and harmless thing to try, so don’t skip it.
- Delete your browser’s cookies. Some 500 Internal Server Error issues can be corrected by deleting the cookies associated with the site from which you’re getting the error.
- After removing the cookie(s), restart the browser and try again.
How to Fix the 500 Internal Server Error
Deactivate all the Plugins
One or more plugins can cause an internal server error. In such a scenario, you can try deactivating all plugins and see if the error goes away.
Access the admin area of your WordPress site and manually deactivate each plugin. If you are not able to access the WordPress admin area, then you can connect to your site using an FTP client.
Once you are connected, go to the wp-content folder. In that folder, there is a folder named “Plugins”. To deactivate the plugins on your site, simply rename the folder to something else. For example, you can rename the folder “Plugins_old”.
Once your plugins are deactivated, you can see if the site is working without any errors. If the error is resolved then you can be sure that one of the plugins was the cause of the error. You can narrow down the culprit by activating each plugin one-by-one and checking the error at the same time.
Change the Theme
If deactivating the plugins does not resolve the error then the next step is to switch your theme. Some theme functions may cause problems. The best way to be sure if the theme is the issue is to revert to a default WP theme and see if the error persists.
If you are not able to access the WordPress admin area, then you can switch to the default theme by simply renaming your current theme file.
Check for Corrupt the htaccess File
Sometimes a corrupt htaccess file may throw an error like a 500 internal server error. To resolve this error, follow these steps:
- Connect to your site using FTP and locate the .htaccess file.
- Rename the file. For example, .htaccess_old.
- Check your site and see if the problem is solved.
If the problems seem to be resolved, then you just need to do one last thing. Go to Settings>>Permalinks in the WordPress Dashboard and click “Save settings” without making any changes. This will create a new .htaccess file with proper rewrite rules that will work well with your site.
You can move on to other options if this error does not solve your problem.
Increase PHP Memory Limit
Sometimes insufficient memory allocated to PHP can cause trouble. You can try increasing the PHP memory limit.
There are three ways to do this:
If you have access to your PHP.ini file then edit the file and add the following line of code.
memory_limit = 256M ;
You may just have to change the value from 64 to 256.
Simply add the following line to your .htaccess file:
php_value memory_limit 256M
Add the following line to the top of your wp-config.php file:
Note that your web host may have restricted the amount of allocated memory you can use, in which case the above code snippets will not work. Check with your web host about the memory limits.
Reupload the wp-admin and wp-includes Folder
Sometimes there is some problem with the wp-admin and wp-includes folder of the WordPress installation.
You can resolve this issue by downloading a fresh WordPress installation file and uploading the “wp-admin” and “wp-includes” folders to your site using FTP.
You will be asked if you want to overwrite the files. Select “Overwrite.” Also, check the box that says “Always use this action” and click OK.
The FTP will upload the WordPress files. If the problem was due to corrupt WordPress files, then this step will resolve the error.
Change File Permissions
The final step you can try to fix a WordPress issue is to try to change the upload folder's permissions.
How can we do that?
- First, connect to your FTP site using an FTP client.
- Go to the root directory of your WordPress site.
- Select all the folders in the root directory. Right-click and select “File Permissions.”
A File Permissions dialog box will open. Enter 755 in the “Numeric Value” field.
Tick the box that says “Recurse into subdirectories.”
Select the “Apply to directories only” option. Click on “OK.”
By now, the error should get solved. If not, you need not be disheartened. You have explored all the options. It is up to your web host to do some work now. We hope this article gave you some ways to tackle a 500 internal server error on your WordPress site. I hope one of these fixes works for you. Did you find another fix? Do share in the comments.
Published at DZone with permission of Shahriar Kabir. See the original article here.
Opinions expressed by DZone contributors are their own.