Categories: WordPress Tutorials

How to Fix WordPress HTTP Error 500

In this article, we will discuss how to fix WordPress HTTP error 500. Since it is one of the most common errors that trouble the beginners, we need to discuss it in detail. Before we get into the topic, you should know that there is a lot of troubleshooting needed to fix 500 internal server error. Basically it is seen when there is a problem either in the file system or the server. Saying this we can expect this problem due to the host server or due to unlikely changes in the WordPress files in the root directory.

What is WordPress HTTP error 500?

When there is an issue with the file system associated with your site, you encounter this error. In addition, 500 Internal Server Error also contains issues related to the web hosting server. Contact your web hosting provider in such a case. 

Either the problem occurs on the server-side or in the path where the WordPress root directory is present. To find out the exact reason for the error, we have to go through different things that are mentioned in this post below. 

How to fix 500 internal server error?

Take your time and follow these steps sequentially to solve this error:

How to fix 500 Internal Server Error

Backup

Always have a backup copy of the existing site at a regular interval of time. This helps you to restore the website at some known earlier date.

Deactivate Themes and Plugins

A theme or a plugin may be responsible for breaking the site if it is not coded properly. They can make changes to the database to cause issues on the site. In case if you are unable to access the admin dashboard, access the files through the control panel.

In most of the hosting providers, you can go to cPanel to locate the directory of the installation of the site. In cPanel, go through Files>File Manager. First of all, you need to deactivate your plugins by renaming the folder name.

You will find the complete list of plugins in the location /wp-content/plugins. You can rename the folder in such a way that you can remember the original name later. For example, by adding a prefix or suffix in the name.

After you have renamed all the plugins, check whether the site is working or not. If the site is back then rename the plugins one-by-one till the site shows WordPress HTTP error 500 again. In this way, you can locate the plugin that is causing the issue on the site.

In a similar fashion, go to /wp-content/themes to manually rename the existing themes one by one. Like above, you may also find the culprit theme if the issue is due to any of the themes. Make sure that you do not deactivate the default WordPress theme.

You can also try improving the theme files by installing it fresh again. While doing this you may need to overwrite the existing files and folder. If you suspect that a hacker has injected malicious code on your website, then you may choose an option to delete the existing theme file before trying to install it again. In such a case, there will be no need to overwrite the files.

If your site comes back, it was due to the theme issue, else continue this troubleshooting process.

Fix .htaccess file

Never edit the htaccess file if you are not sure how the code will behave. Most of the 500 internal server errors are directly related to this file. As we have a backup of the site, try keeping the fresh copy of htaccess file to see if there is any sign of improvements. While doing this, you can also download htaccess file separately as it will help you to restore htaccess quickly instead of using a backup of the whole site. Of course, in case of unexpected changes.

You can find htaccess file in the WordPress installation directory. It is a hidden file, so you must change settings to view the hidden files if any htaccess file is present in the site.

When you have a copy of the existing htaccess file, delete the file and create a new one.

Keep this code inside that file:

# BEGIN WordPress
</IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

For details about htaccess, visit htaccess handbook published by WordPress.

Double-check this file before saving, as even a typo error can break the site. If your site was down due to htaccess, you may be able to recover the site with this method.

Increase PHP Memory Limit

If you have followed the above steps and still not been able to solve WordPress HTTP error 500 then try this as well. Due to the insufficient PHP memory, the plugins and scripts do not load properly and show an error.

This will solve the problem if the site’s PHP memory was unable to handle the browser request previously.

Check PHP version

Have a look at the installed plugins and themes. There are conditions when they require a specific version of PHP. However, you need to be sure that you are updated with the latest version of PHP if there are no such requirements.

If you do not know how to check the PHP version. Take a look at this post:

Replace Core Files

Similar to replacing theme files, you can also replace core files in WordPress. The core files may cause a problem due to a mismatch syntax or conflicting file permissions. To know whether it was the cause for WordPress HTTP error 500, you should try overwriting these files with the original copy. The original copy should be downloaded from WordPress.org

When the core files have been replaced, check whether the site comes back or if there is still 500 internal server error. Since you already have a backup of the site, it will be useful further unless the site is working properly.

Enable Debugging and Logging

If you are a developer then you would probably try this option in the beginning. Since your site is not back, you should enable the debugging mode to find the exact reason for the issue. You should take a note that debugging enables reporting at the front-end. Furthermore, you should also enable logging so that users do not see the site error messages. This is a necessary step as the error information can be used to hack the site by malicious users.

Consider adding the following lines of code in the wp-config.php file:

// Turn debugging on
define('WP_DEBUG', true);

// Turn log on to /wp-content/debug.log
define('WP_DEBUG_LOG', true);

// Turn off error messages
define('WP_DEBUG_DISPLAY', false);

// Hide errors from on-screen
@ini_set('display_errors', 0);

Add the debug and log code above the following line:

/* That's all, stop editing! Happy blogging. */

We do not use debugging in live sites. However, when there is no option, you can turn off Front-end error reporting to continue to debug. When you have completed debugging turn off the debugging mode by changing the code from true to false.

Contact your Hosting Provider

It’s a wise option to contact and inform the hosting provider. The problem may have arisen from the host itself. They will check and let you know if the allocated resources are giving WordPress HTTP error 500.

In the case of insufficient resources, you need to upgrade your hosting plan to the one that can manage your site.

Wrapping Up

Hopefully, you have learned how to fix 500 internal server error. You will get the solution if you have followed our instructions carefully. If you face any problem while implementing solution for WordPress HTTP error 500, feel free to ask the solution from us in the comment section below. 

Additional Posts

Amar Raj Mahato

Amar Raj Mahato is a Digital Marketer who is currently working as a content creator and SEO specialist in CodeFlist.com

Recent Posts

How to fix 504 Gateway Timeout Error?

As a visitor of the site and website owner, it is awful to experience errors on the site. Error pages… Read More

2 years ago

How to fix 403 Forbidden Error?

In the present context, every business owner maintains their own site for the online presence. When something unexpected happens with… Read More

3 years ago

How to use WebP images in WordPress?

If there are too many images on your site, they are uploaded in either PNG or JPG format. Learning how… Read More

3 years ago