Did you just experience a 500 error on your WordPress website? Don’t panic. In this post, we’ll cover an example of how to fix a 500 error so you can quickly get your site back online.
What is a 500 Error?
A 500 Internal Server Error is an HTTP response status code. This means the server responded to an HTTP request by saying it encountered an error that it can’t recover from.In plain English, a 500 error means your server has a problem.
What causes a 500 error?
A 500 error is a generic server error. Quite a few things that can contribute to a server responding with the status. A 500 error is actually helpful because it narrows the problem down to your server.
The following are examples of what could be causing the 500 error and how to fix them:
1. Errors in the .htaccess File
A single extra character added to the .htaccess can cause the file to become corrupted. You can try to generate a new .htaccess to see if it helps. Delete the site’s current .htaccess and then save the WordPress Permalinks setting to generate a new .htaccess file.
2. Errors in the wp-config.php File
If there was a rule that was added incorrectly or written in the wrong code block, it could be too much for your server to handle. Your error logs will likely give you the exact line that is causing the server error. If you do not have error logging enabled, you will be required to do a little more legwork. Remove all of the non-WordPress code in the wp-config.php file. Now you can re-add it one code block at a time to narrow down what is causing the issue.
3. Inadequate File Permissions
If a PHP script that is needed to is located in a folder that isn’t allowed to run PHP, it can cause a 500 error. You can fix this by changing the file permissions or ownership to allow the file to execute PHP.
4. Server/Script Timeouts
Timeouts are the most common cause of 500 errors. A timeout is typically due to the server running out of resources in the middle of a job. If you run into a timeout error, you may see advice to manually increase the PHP memory and max_execution time in the PHP.ini, wp-config.php or .htaccess files, but I would suggest asking your host make the increase for you. You can change manually change your PHP memory and max_execution time to whatever you want but if your host has set a hard cap, the changes you make will not do anything.
A plugin on your site could cause a fatal PHP error if it runs into any issues when trying to execute code. You can disable the plugin causing the error to get the site back online while you troubleshoot the PHP error.
How to Fix a 500 Error
Now let’s unpack how to fix a 500 error if you’re seeing one on your WordPress website.
1. Check your website’s error logs.
To check your site’s error logs, you will need to log into your server via SFTP using your favorite FTP client. I personally use FileZilla, but there are many options available. After logging into the server, you will need to find your logs directory and then open your error log in a text editor.
If you don’t know what your SFTP username and password are or where your logs are stored, you can ask your host, and they will be able to answer both of these questions for you.
2. Find the most recent error in your error logs.
Now that you have your error log open, scroll to the bottom of the page to find the most recent error, which will give you a clue on how to fix the 500 error.
Looking at the error below, we can see that I currently have a PHP Fatal error.
PHP Fatal error: require(): Failed opening required '/home/mmoore/public_html/sync/wp-content/plugins/ithemes-security-pro/core/core.php' (include_path='.:/usr/local/lib/php') in /home/mmoore/public_html/sync/wp-content/plugins/ithemes-security-pro/ithemes-security-pro.php on line 77, referer: https:/yoursite.com/sync/wp-admin/plugins.php
At first glance, the error can look pretty confusing and intimidating. But let’s break the error into bite-size pieces, so it is easier to digest.
PHP Fatal error: require(): Failed opening required
The first bite is letting you know what type of error you are dealing with, which in our example, we have a PHP error. We can also see that the cause of the error is something that is required failed to open.
The next bit is letting you know where the PHP error is occurring, it is also known as the directory path.
3. Apply a temporary fix to get the site back online.
We can see that the source of the error may be coming from a plugin installed on the site, iThemes Security Pro. So before we continue to investigate the error, we should try disabling the plugin to see if that can be a temporary band-aid to get the site back online.
To do this, you’ll need to navigate to the plugins directory on your website from your FTP client.
If you’re new to browsing the files on your website, each / is a new folder. When you log into your server using an FTP client, you will likely start in the home directory of your website.
From the home folder, you will need to open the folder where your website resides (in this example, <tt?mmoore). Then you will open the public_html and follow the directory path to the plugins directory.
Now that we are in the plugins directory, we can manually disable the plugin by renaming the plugin folder. To do this, you can add .bak to the end of the folder name to make the new file name (for example: ithemes-security-pro.bak).
The plugin is now disabled, so let’s see if that help to bring the site back online.
Now, go back to your browser and reload the page to see if we still see the 500 error.
Great, we no longer see the error and the site is online! But our job isn’t finished. We only applied a temporary fix, and we need to finish the job. Let’s go back to the error logs.
4. Fix the source of the error.
We already looked at the first couple bits of the error, but let’s finish breaking down the error so we can figure out why our site went down in the first place.
(include_path='.:/usr/local/lib/php') in /home/mmoore/public_html/sync/wp-content/plugins/ithemes-security-pro/ithemes-security-pro.php on line 77 referer: https:/yoursite.com/sync/wp-admin/plugins.php
The next portion of the error is showing the file that requires the core.php file from the section of the error, and where we can find the file. The refer: is showing that the script that triggered the error was triggered from the sites plugin’s page.
Following the directory path, we can see we need to open the ithemes-security-pro.php file and look at line 77.
require( "$itsec_dir/core/core.php" );
Now the error is starting to make a little more sense. On line 77 of the ithemes-security-pro.php file, it is showing that the core.php file is required for the plugin to work. That is why we have the
PHP Fatal error: require(): Failed opening required in our error logs.
Time to go back to our FTP client and follow the directory path to find the core.php file. There isn’t a core.php file in the
public_html/sync/wp-content/plugins/ithemes-security-pro directory. That would definitely cause the iThemes Security Pro plugin to fail.
Luckily, if you ever run into this it is a super easy and quick fix. Simply download a new version of iThemes Security Pro plugin and replace the corrupted version that is currently installed on our site.
Using our FTP client, we will need to navigate into the /wp-content/plugins/ directory. From there, we can upload the folder containing the version of iThemes Security Pro we downloaded.
A cool thing about replacing iThemes Security Pro via FTP is that all of your settings will be saved. iThemes Security stores your settings in the database, so replacing the server files will not disrupt your configuration.
Now that we have replaced the corrupted version of the plugin we can safely reactivate iThemes Security Pro on the site.
That is it, and now you know how to fix 500 errors on your WordPress site.
- 1. Check the error logs.
- 2. Apply band-aid fix to get the site back online.
- 3. Fix the source of the error.
Watch the Video: How to Fix a 500 Error
In this video tutorial, we show how to fix 500 errors in action.