How to Fix 500 Internal Server Error in WordPress?
What is a 500 Internal Server Error?
One most common error that a WordPress website owner comes across as is a 500 internal server error. These errors are frustrating because they don’t have a specific reason and can be confusing to figure out what went wrong.
500 Internal server error is an HTTP status code indicating that there is some issue on the host server or within the root directory. However, the cause of this error doesn’t necessarily have to be based on one single reason. There are multiple instances when this status code is displayed and is rarely an actual server error.
An internal server error is not exclusive to WordPress, it can occur on any website at any time. Most of the time an internal server error is displayed as an error message or simply a blank white page. Meanwhile, bigger brands have their custom error message for internal server error.
If you are in need of professional assistance to fix 500 internal server error for your WordPress website, feel free to connect with our team of expert web developers.
In this article, we’ll be telling you some good solutions to fix Internal server error.
1. Reload the page
Let’s start with the very basic step: try loading the page again. If a website is being reloaded while it’s processing the old request, a new request will be sent to the server at the same time with the first one forcing the server to respond.
Another way to identify the issue is to make use of sites (tools) that check whether a website is down or not. If these tools receive anything other than HTTP 200 status code (Everything is OK), then it indicates that the website is down.
2. Clear browser history
Clear the browser history and then try to reload the page. This should be one of the first steps to be taken before proceeding with any deeper debugging step on your website.
3. Debugging
WordPress offers a provision to debug using its built-in debugging feature. Debugging may not necessarily fix the problem but it can provide some insights on the issue.
Here’s WordPress’s debugging process explained in simple steps.
- Access your site’s wp-config.php file from the root folder of the website.
- Inside the file, search for “WP_DEBUG” (which is a PHP constant used as a permanent global variable for debugging purposes in WordPress).
- Now set the variable WP_DEBUG as “true” to start with the debugging process.
It should look like this:
define( “WP_DEBUG”, true );
Reload the website after saving this change and if this error gets fixed, a new error will definitely pop up. Now, this new error will help you figure out what the exact problem is. Moreover, you may observe the error location and fix it right away! If it points to a plugin folder, you can easily deactivate the plugin to remove the error.
4. Plugins and themes
Plugins and themes are an inevitable part of WordPress and there are chances of encountering a 500 internal server error because of this. An error can occur immediately after installing a plugin/theme or while running an update for the same.
One way to troubleshoot this is to deactivate all your plugins and reload the website to check if they were the ones causing the error. Deactivation is recommended over deletion because you wouldn’t lose any of your data in the former
Now reactivate them one at a time and try reloading the website each time. This way you can easily figure out the plugin causing the problem. You can connect with the plugin developer and ask for help or post about it in the WordPress support forum.
If this doesn’t work because you are unable to access the admin side, access your FTP server, SFTP server or hosting account’s Cpanel dashboard. Rename all the plugins folder as something like old_plugins and try reloading the website again.
If the site gets reloaded, you rename the folder to its old name, start renaming each plugin inside the folder and simultaneously reload the website. If this works, you’ve figured out the culprit!
The same thing goes with the theme as well, at times certain themes can cause such errors (while installing or updating). Check the themes just like the way you did with the plugins. Also, use the WordPress default theme (optimized theme) if there are any theme related issues.
5. Database connection error
A database connection error is the most commonly observed error in WordPress. This error occurs when there is an error while the PHP code tries to establish a connection with the MySQL database. As the website is unable to establish a connection with the server, this error is always shown on a blank page.
This can occur for 2 reasons; one simple reason is that the login credentials may be incorrect, while the other one is that there are chances for a database error.
6. Reinstall WordPress
At times some old sites can get an internal server error when some core WordPress files get corrupted. Reinstalling WordPress can be done without affecting the already installed plugins or themes.
Try re-uploading the wp-admin and wp-includes folders once the new WordPress is installed using these simple steps:
-
-
- Download the WordPress zip file from the WordPress.org site.
- Extract the WordPress file and access the WordPress folder.
- Connect the WordPress website via an FTP client.
- Once you get the access, you can view the folder which contains wp-admin, wp-includes, and wp-content.
- Open the WordPress folder from your computer and select wp-admin & wp-includes to upload them.
- The FTP client now transfers the file to the server and asks if it should be overwritten.
- Now select ‘overwrite’ and ‘Always use this action’.
-
7. Permission error
Sometimes even a permission error can be a reason showing an internal server error. Even though the chances of such an error occurring is very less, let’s not spare a possibility to remove error 500.
Access your WordPress root directory using an FTP client and check if the permission for files and folders are set to either 755 or 644. Also, remember setting it to any other number would cause an error.
8. Expand PHP memory limit
An exhausted PHP server memory can be one reason for an internal server error. This can be resolved if the PHP memory limit is increased.
There are chances for a 500 error code showing up while trying to log in the WordPress admin or when uploading an image in wp-admin, at those instances you can expand the memory limit using the following steps.
-
-
- Create a new file, php.ini in the root directory
- Write the code, memory=64MB on it.
- Save and upload it in wp-admin via FTP server, SFTP server or hosting account’s Cpanel dashboard.
-
Or the same thing can be done by accessing your site’s wp-config.php file from the root folder of the website and search for “WP_MEMORY_LIMIT” within. Now change its value to “64M”.
It should look like this:
define(‘WP_MEMORY_LIMIT’, ’64M’);
Don’t be relieved if this code fixed your error, now you need to figure out what is exhausting the PHP memory. A poorly-developed plugin or theme function can cause this, while it’s highly recommended if you can contact your hosting provider and get details from the server logs.
9. Check your .htaccess file
A corrupted .htaccess file is one of the most common reasons for internal server error if your WordPress host is running on Apache.
Access your FTP server, SFTP server, or hosting account’s Cpanel dashboard and rename your .htaccess file into .htaccess_old. Now, if the website reloads, the error is fixed!
You can create a new .htaccess file with the following contents, and then upload it to the server.
# 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
Or you can directly go to Settings » Permalinks page in the WordPress admin part and save the data on it without making any changes. This action will generate a new .htaccess file.
10. PHP timeouts
Error 500 can occur during PHP Timeouts. A PHP timeout is a result of a lack of PHP workers.
For example, you have 4 requests coming to the website at the same time, with you having only 2 PHP workers. Now 2 requests out of them would be processed immediately while the other 2 requests need to wait until the others finish.
Processing further requests can happen instantly if there are no complex themes or a lot of plugins used on the website. The problem arises when there are too many requests and it would be left uncached if the PHP workers can’t handle them. So it’s always advisable to estimate the number of PHP workers you require for the website and work over it.
Conclusion
When the website goes down, you are losing a lot of visitors and affecting website traffic seriously along with degrading the brand name! On top of that, Google detects such occurrences on a website and can demote the website to alert that the error needs to be addressed.
Make sure that all your website’s plugins, themes, and WordPress core files are up-to-date. Ensure that the theme you use is compatible with your plugins.
Use tools that monitor any kind of error occurring on your website so that you can have a track on them. These tools can alert you whenever the site goes down by simply sending you an email. This also means that it can monitor and pass information to you even at an interval of 15 seconds.
Ask your hosting provider for support if all these techniques didn’t help you figure out the reason for a 500 internal server error. You can ask them to check the server logs and identify the root cause for the error.
If all of this seems confusing to you, do not worry! Our team of expert website developers can definitely help you fix the 500 internal server error for your WordPress website.