Why Am I Getting HTTP 500 Internal Server Error on my WordPress Site? (with Video)

HTTP 500 Internal Server Error

Last updated - July 8, 2021

If you have a WordPress site, one of the common errors that you may encounter will be HTTP Error 500. This could be really confusing for site owners, particularly so if you are a beginner of WordPress. What will you do if you are getting HTTP Error 500? And why are you getting this error? You may have to find out the reasons for the error and then try out different options to fix it. In this article, we will discuss some of the reasons for HTTP Error 500 and the ways to fix it.

Understanding HTTP 500 Internal Server Error

An Internal Server Error is displayed when your server is not able to display the requested page. It can be issue on your web server, and is somewhat of generic nature. From this error, you may not be able to understand much the underling cause. There are several common reasons for this error, which includes the misbehavior of a plugin or theme that you have installed. It could be also due to a corrupted .htaccess file or problems with the PHP memory limit.

Now, we will look into the possibilities that might help you troubleshoot this error.

Enable debugging

One of the first strategies that you can try out to troubleshoot an error on WordPress would be to turn on debugging. Now, this will not resolve the issue for you, but it will help you figure out what is wrong.

To turn debug mode on, you will have to access the wp-config.php file. When you search for the content inside this file, you should be able to find WP_DEBUG. This has to be set to ‘true’ to enable debugging. If you are not able to find WP_DEBUG within your wo-config.php file, you can simply create it.

Basically, you need to have the following code in the wp-config.php file to turn on debugging.

define( "WP_DEBUG", true );

Now, if you try to reload the site, there is a chance that the error has changed. There is a chance that now the error has changed and the new error is pointing to a specific line of code with the issue. This will actually help you understand the exact nature of the problem, and you can directly address it and fix it. For example, if the error is pointing to a plugin or theme, you can simply disable that to get rid of the issue. If there is no change after turning on debugging, you can still keep it as ‘true’ until the issue is resolved.

Try a debugging plugin

You can use a debugging plugin that will help you identify problems. Here is a popular one:

Query Monitor

This plugin will help you with the debugging of different problems that you may encounter on your site. These include database queries, PHP errors, debugging of AJAX calls, identifying performance issues with plugins, etc. It helps you identify problems on your site through an organized display of debugging information of a page.

HTTP 500 Internal Server Error
This plugin helps you in debugging different WordPress problems.

Clear Your Browser Cache

Clearing your browser cache is a good initial troubleshooting step that might be worth trying. Though the process might differ for various browsers, here’s how you can clear browser cache for Google Chrome.

Find and click the three dots icon in the top right of your browser. Then, head to More tools > Clear browsing data.

HTTP 500 Internal Server Error
Accessing the “Clear browsing data” setting from your cache.

A new window will open with a “Clear browsing data” popup. Here, make sure you’ve only selected the “Cached images and files” option as we don’t want to remove saved passwords, cookies, and browsing history right now.

At the top, you can also choose a time range for clearing the browsing cache. Then, just click “Clear data”. Your Chrome browser cache is now empty.

HTTP 500 Internal Server Error
Clearing the browser cache in Chrome.

Check the plugins and themes

Sometimes, when you are facing internal server error, you may still be able to access the WordPress admin page. If this is the case, you can check if one of your plugins or themes is causing the issue. For this, first, you can deactivate all the plugins on your site, and then try and reload the site. If the error has disappeared that means the issue was with one of the plugins. Now, you can activate the plugins one by one and see if the error reappears. This way, you can easily figure out if one of the plugins is causing the error.

If you can’t identify a problem with the plugin, there is a chance that your theme is creating the issue. The best way to know this is by switching to the default WordPress theme. If your site is loading fine after this, that means the issue is with the theme. You can contact the customer support of the theme, or get the help of a developer to find the specific issue with the theme.

Increase the memory limit

One of the reasons for internal server error could be the memory limit on your site. Sometimes, a badly-coded plugin or theme will be cause for exhausting the memory limit. Even though it is not a permanent fix for the problem, you can temporarily avoid the error by increasing the memory limit. Experts warn that this is not a recommended fix, and you should investigate further to understand what is exhausting the memory.

Just like you enabled debugging, you can find the wp-config.php file from your root WordPress install. Search for the following line in the file:

define('WP_MEMORY_LIMIT', '32M');

You can simply increase the memory limit by specifying a higher value here. For example, you can replace this line as given below:

define('WP_MEMORY_LIMIT', '128M');

This should be good enough to help you get over the error if memory limit is the issue. You can also contact your hosting service to understand if there is an issue with the server. If the server is not really optimized for a seamless WordPress experience, you can even consider switching to another hosting service. These kind of problems related to the server can often be seen with shared hosting services.

Fix problems with your .htaccess file

The .htaccess file holds a few server configuration rules that could be critical to the functioning of your site. Any problems inside the .htaccess file could lead to the error. Now, how will you find out if the problem is actually due to a corrupted .htaccess file?

Use FTP to find if there is a .htaccess file in your WordPress root directory. Make sure hidden files are visible on the FTP editor. If you are able to find the .htaccess file, you can create a backup of this file by renaming it. Now, you have to delete the original .htaccess file and all its contents. After this, you can try reloading the site. If the problem was with a corrupted .htaccess file, deleting the file and its contents will solve the issue for you.

You can create a new .htaccess file by accessing Settings > Permalinks and simply clicking the Save Changes button.

Check your PHP version

You need to find out the PHP version that is running your site. Simply using an older version of PHP will not cause an internal server error. However, if a plugin is using functions that is not available on older versions, it can result in an error. Contact your hosting service provider and find out the version of PHP that you are running. If it is a really old version, request them to update to the latest version.

Re-uploading core WordPress files

In most cases, this won’t be a definite solution to the problem. However, experts suggest to try this out if none of the other strategies are working for you. Before doing this, you should create a backup of your site, and then download a fresh version of WordPress.

HTTP 500 Internal Server Error
You can download a fresh version of WordPress and replace the wp-admin and wp-includes folders.

Access your site’s root directory using FTP client, and replace the existing wp-admin and wp-includes folders with new versions. Refresh your site and if the error is gone, you can assume it is due to a corrupted core file.

Fix the Error Establishing a Database Connection Issue

Database connection errors can also cause 500 internal server errors to occur. And though it also generates a 500 HTTP status in the server log, you’ll get an “Error establishing a database connection” message in the browser.

This issue can be caused by incorrect database login credentials, corrupted WordPress database or files, or due to other issues with your database server. Here are some easy fixes for this issue:

  1. Check whether your database login credentials are correct.
  2. Repair a corrupt database with WordPress’ built-in database repair mode: define(‘WP_ALLOW_REPAIR’, true);
  3. Fix corrupt files
  4. Check with your hosting provider for issues related to your database server.
  5. Restore to your latest backup.

Eliminate any WordPress Permissions Errors

If your file or folder on your server has a permissions error, you’ll see a 500 internal server error. You can see these file permissions using an FTP client. Here are some recommendations to follow regarding WordPress file and folder permissions.

  • All files should be 644 (-rw-r–r–) or 640.
  • All directories should be 755 (drwxr-xr-x) or 750.
  • No directories should be given 777, including upload directories.
  • Hardening: wp-config.php could be set to 440 or 400 to prevent other users on the server from reading it.

Identify if there are more than one issue

There is a possibility that there is a combination of issues that is leading to the internal server error on your site. It is important that you are able to identify if this is the case. One way you will be able to identify this will be if you try out the above mentioned troubleshooting steps in a sequence. Ensure not to undo the changes after each step, so even if more than one is causing the trouble, you will be able to identify them.

Contact your host

If you have tried troubleshooting the HTTP 500 Internal Server Error with all the available strategies, you may contact your hosting service provider. Sometimes the problem will be from the hosting service’s end, which you may not be able to control. However, it is always better that you go through the above mentioned to rule out an issue from your WordPress root directory.

They will be able to go through the server log and identify the real cause of the error. Most of the good hosting service providers will have a good customer support team to help you out in case of real server issues.

Generally, internal server error can be a frustrating experience for WordPress beginners. It is due to the ambiguous nature of the error that it often needs an expert to identify the root cause of the error. You can always opt for the services of one of the popular WordPress maintenance service providers if you don’t want such issues to recur.

If you prefer a video version, please check the video below:

Further reading

LEAVE A REPLY

Please enter your comment!
Please enter your name here