An internal server error (500) – a WordPress site crash always seems to occur at the most inconvenient time, leaving you scrambling for a solution. Trust us, we’ve all been there. The daunting error of establishing a database connection and the dreaded white screen of death are also similar errors that can occur. From the moment your site goes down, you start losing visitors and customers. Unfortunately, your brand also suffers as a result.
Today, let’s discuss the 500 internal server error and how to resolve it. Here are some tips on preventing this error in the future and identifying its causes.
The most common causes of the 500 Internal Server Error are
Several factors can cause WordPress 500 Internal Server Errors. If you are experiencing this issue, one or more of the following elements is likely responsible for it:
- The browser cache.
- Login credentials are incorrect.
- A corrupt database.
- WordPress installation corrupted.
- Database server issues.
- Files corrupted by WordPress.
- PHP memory limit and corrupt .htaccess file.
- Themes and plugin issues.
- With third-party plugins, PHP times out.
- Permissions are incorrect.
- PHP memory limit reached
- A broken or corrupt .htaccess file.
- Perl and CGI errors.
How do I fix a 500 error?
Websites are hosted on servers that receive requests from your browser. The server processes these requests, and resources (such as PHP, HTML, CSS, etc.) are sent back with an HTTP header. The HTTP protocol also includes a status code. You can obtain a status code by checking the status of your request. A 200 status code indicates that “Everything is OK,” while a 500 status code signifies that something went wrong.
Analyse
A 500 status error code can mean many different things (500, 501, 502, 503, 504, etc.). It indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.
Internal Server Errors
An internal server 500 error can appear in many different ways depending on the web server, operating system, and browser. The message they all convey is the same. A few examples of the many variations you might come across online are listed below:
- “500 Internal Server Error”
- “HTTP 500”
- “Internal Server Error”
- “HTTP 500 – Internal Server Error”
- “500 Error”
- “HTTP Error 500”
- “500 – Internal Server Error”
- “500 Internal Server Error.” Sorry, something went wrong.”
- “500. That’s an error. There was an error. Please try again later. That’s all we know.”
- “The website cannot display the page – HTTP 500.”
- “Is currently unable to handle this request. HTTP ERROR 500.
Additionally, you may see the following message:
Your request could not be completed due to an internal error or misconfiguration on the server. You should contact the server administrator at webmaster@domain.com and tell them when and how the error occurred. The server error log may provide more details about this error.
You might also see a blank screen from time to time. Firefox and Safari are quite common browsers that cause 500 internal server errors.
There may even be custom 500 internal server error messages for some brands.
The 500 error is more closely associated with the following HTTP status codes on Windows servers:
- Error 500.0 – Module or ISAPI error.
- 500.11 – Application shutting down on the web server.
- 500.12 – On the web server, the application is restarting.
- 500.13 – Too many requests.
- 500.15 – A direct request to global.asax is not allowed.
- 500.19 – Invalid configuration data.
- 500.21 – The module is not recognised.
- 500.22 – Managed Pipeline does not support ASP.NET HTTP modules configurations.
- 500.23 – Managed Pipeline does not support ASP.NET HTTP handlers.
- 500.24 – Managed Pipeline does not support ASP.NET impersonation.
- 500.50 – Rewrite error during RQ_BEGIN_REQUEST notification handling. There was an error configuring or executing rules.
- 500.51 – In GL_PRE_BEGIN_REQUEST notification handling, a rewrite error occurred. There was an error executing global rules or configurations.
- 500.52 – Rewrite error during RQ_SEND_RESPONSE notification handling. Outbound rule execution occurred.
- 500.53 – RQ_RELEASE_REQUEST_STATE notification handling error 500.53. An outbound rule execution error occurred. The rule is configured to be executed before the output user cache updates.
- 500.100 – Internal ASP error.
SEO and 500 errors
Unlike 503 errors, which are used for WordPress maintenance mode, a 500 error can have a negative impact on SEO if not promptly resolved. If your site experiences a 500 error and remains down for a significant period, it may be served from the cache during consistent crawling, such as for 10 minutes. Even if your site is back up before Google re-crawls it, you should be unaffected in this scenario.
However, if your site remains down for more than 6 hours, Google might perceive the 500 error as a site-level issue requiring attention. This can potentially impact your rankings. Therefore, it is crucial to identify the root cause of 500 errors if you wish to avoid their recurrence. The following solutions may prove helpful.
Fixing 500 Internal Server Errors
When your WordPress site displays a 500 internal server error, it can be challenging to determine where to start troubleshooting. Usually, server-related issues are responsible for 500 errors. However, based on our experience, these errors can stem from two sources: user error (client-side issue) and server problems. Here, we’ll provide insights into both aspects to help you quickly restore your site’s functionality.
Get back up and running quickly with these common causes and solutions.
Browser Cache Clear
To begin troubleshooting your website, it’s recommended to clear your browser cache. Simply search on Google for “how to clear browser cache” followed by the name of your browser (e.g., Chrome, Firefox, Safari, Opera). Follow the instructions provided in the search results, usually the first one.
Server logs
Using your error logs is also a good idea. If your hosting provider does not provide a WordPress debugging mode, you can enable it by adding the following code to your wp-config.php file:
- define( ‘WP_DEBUG’, true );
- define( ‘WP_DEBUG_LOG’, true );
- define( ‘WP_DEBUG_DISPLAY’, false );
Typically, logs are located in /wp-content. Others might have a dedicated “logs” folder.
Log files from Apache and Nginx are located here, and you can check them as well:
- Apache: /var/log/apache2/error.log
- Nginx: /var/log/nginx/error.log
You can also try enabling PHP error reporting if a fatal PHP error causes the 500 error. The error can be fixed by adding the following code to the file throwing the error. In Chrome DevTools’ console tab, you can narrow down the file.
- ini_set(‘display_errors’, 1);
- ini_set(‘display_startup_errors’, 1);
- error_reporting(E_ALL);
In addition, you might need to modify your php.ini file:
- display_errors = on
Error Establishing a Database Connection
A database connection error can also cause 500 internal server errors. You may see different errors depending on your browser. Regardless of the HTTP status code, both will generate a 500 error message in your server logs.
An in-depth blog post on “Error Establishing a Database Connection” can be found here. The instructions in this post can help you get to the root of the 500 error if it is related to a database.
Plugins and Themes
Third-party plugins and themes can easily trigger 500 internal server errors. At Kinsta, we have witnessed various types of plugins causing such errors, ranging from slider plugins to ad rotator plugins. Often, these errors occur immediately after installing something new or performing an update. That’s why we always recommend using a staging environment for updates or implementing them one at a time. When faced with a 500 internal server error, it becomes crucial to identify the plugin responsible.
To troubleshoot this issue, start by deactivating all your plugins. Deactivating a plugin does not affect your data. The simplest way to do this is by navigating to the “Plugins” section and selecting “Deactivate” from the bulk action menu. By doing so, you will disable all your plugins.
Next, you need to determine the source of the problem. Begin by activating each plugin one by one and reloading the page after each activation. If a 500 internal server error reoccurs, you will be able to pinpoint the misbehaving plugin. Alternatively, you can submit a support ticket to the plugin developer for assistance.
If you are unable to access the WordPress admin panel, you can rename the plugins folder to something like “plugins_old”. Then, check your site again. You will need to systematically test each plugin folder by renaming them back to “plugins” and then renaming each folder inside it one by one until you identify the problematic one. Performing this on a staging site would also be a recommended approach.
Updating your plugins, themes, and WordPress core is always a good idea. Make sure you are running a supported version of PHP. It might be necessary to hire a WordPress developer if there is a conflict with bad code in a plugin.
Install WordPress again
WordPress core files can occasionally become corrupted, particularly on older sites. Re-uploading the core files of WordPress itself will not impact your plugins or themes. However, before proceeding, it is crucial to create a backup of your website.
Reinstalling WordPress is a straightforward process. If you encounter any difficulties, you can search on Google to find the most helpful article on uninstalling/reinstalling WordPress.
Unauthorised
A permissions error can also cause the 500 internal server error on your server. As a general rule, WordPress recommends the following permissions for files and folders:
- All files should be 644 (-rw-r–r–) or 640.
- All directories should be 755 (drwxr-xr-x) or 750.
- Even upload directories should never be given 777.
- To prevent other users from reading wp-config.php, it can also be set to 440 or 400.
PHP Memory Limit
The PHP memory limit on your server could potentially result in a 500 internal server error. It is advisable to consider increasing the limit. Below are instructions for adjusting this limit in cPanel, Apache, php.ini, and wp-config.php within WordPress.
Increasing PHP memory limit in cPanel
On a host that uses cPanel, you can easily change this. Click “Select PHP Version” under Software. Go to “Switch to PHP Options.”. Click on the memory_limit attribute to modify it. Click “Save.”
Increase PHP Memory Limit in Apache
You can modify the server behavior to a directory-specific level using the .htaccess file. Look for a .htaccess file in your root directory by logging in via FTP or SSH.
The code for increasing the PHP memory limit can be added to that file if there is one. The most likely value is 64M or less, so you can try increasing it.
- php_value memory_limit 128M
PHP Memory Limit in php.ini
You might try editing your php.ini file if the above doesn’t work. If you’re using FTP or SSH, you can open a php.ini file by going to your site’s root directory. If the file already exists, search for the three settings and modify them if necessary. If you just created the file or cannot find the settings, you can paste the code below. The values can be modified to meet your needs, of course.
- memory_limit = 128M
For the above php.ini file settings to work, you might also need to add the suPHP directive to your .htaccess file. You can do this by editing your .htaccess file, also located at the root of your site, and adding the following code at the top:
<IfModule mod_suphp.c>
suPHP_ConfigPath /home/yourusername/public_html
</IfModule>
Your host might have the global settings locked down and have it configured to use .user.ini files instead if the above did not work for you. Open or create a .user.ini file in your site’s root directory using FTP or SSH. Paste the following code:
- memory_limit = 128M
In wp-config.php, raise the PHP memory limit.
As a last resort, you can try the last option if all else fails. Locate your wp-config.php file, usually found in the root of your website, by logging in via FTP or SSH. In your wp-config.php file, add the following code:
- define(‘WP_MEMORY_LIMIT’, ‘128M’);
.htaccess Problem
Using an Apache-based WordPress host, you may have a problem with your .htaccess file. Create a new one from scratch by following the steps below.
Your .htaccess file should be renamed to .htaccess_old after you log in via FTP or SSH. In WordPress, you can re-save your permalinks to recreate this file. In the case of a 500 internal server error, you won’t be able to access your WordPress admin. You can therefore create a new .htaccess file and enter the following contents. Upload it to your server after that.
# 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
CGI/Perl code errors
It is becoming less frequent to encounter 500 errors caused by CGI and Perl issues. However, cPanel users, especially those utilising one-click CGI scripts, should still be mindful of this. When dealing with CGI scripts, here are a few helpful tips:
- Edit plain text using tools like Atom, Sublime, or Notepad++ to ensure the files remain in ASCII format.
- Make sure to correctly set the file permissions using chmod 755 for CGI scripts and directories.
- Upload your CGI scripts to the CGI-bin directory using your FTP editor, ensuring that you select ASCII mode for the transfer.
- Verify that the required Perl modules are installed and supported for your scripts to function properly.
Server Issue
You can also ask your WordPress host about 500 internal server errors caused by PHP timing out or fatal PHP errors caused by third-party plugins since 500 internal server errors can also occur from PHP timing out. Often, these errors can be difficult to troubleshoot without expert assistance. Listed below are some common errors that can trigger 500 HTTP status codes on the server.
PHP message: PHP Fatal error: Uncaught Error: Call to undefined function mysql_error()…
PHP message: PHP Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in /www/folder/web/shared/content/plugins/plugin/functions.php:525
We can help
As a successful WordPress agency, we know every in and out of WordPress, and if you are still stuck and unable to figure it out, let us assist.