How to Fix the 500 Internal Server Error in WordPress

How to Fix the 500 Internal Server Error in WordPress

The 500 Internal Server Error is one of the most common panic-inducing “I’ve broken everything!” catch-all errors in WordPress that can literally mean anything.

The most common reasons for WordPress throwing up this error include having a corrupted .htaccess file, exceeding your PHP memory limit, or having improper file permissions, but there could also be other potential causes, such as outgrowing your hosting plan or a known issue with your hosting provider.

No matter what the cause, there are many ways to troubleshoot and fix your site, including restoring your site from a backup to simply turning on WordPress debugging mode.

In today’s post, I’ll go through the best ways to troubleshoot the 500 internal server error in WordPress so you can fix your site. If you’re experiencing the error right now and looking for a straight forward solution, start from the top of this post and work your way down the list until you have identified the issue, resolved it, and your site is back in business.

Note: If you’re still having trouble with error, let us help! Our awesome support team can help you with any WordPress issue, big or small – and for free! It doesn’t matter what time it is or whether it’s the weekend, our team is available 24/7.

1. Backup and Restore

Since you need to make serious changes to some of your core files and other similar changes, it’s a good idea to backup your site in case things get worse. That way, you can restore your site back to the beginning of the error so you have less to clean up.

The only thing better than this kind of backup is one where your site is working properly. If you have this kind of backup, go ahead and restore your site since some recent changes may have been the cause.

If not, you can start by making a manual backup of your entire site just in case. You can check out How to Manually Backup Your WordPress Website
for details on how to create a manual backup.

2. Deactivate Plugins and Themes

Sometimes, a plugin or theme could be the cause of the error and the reasons for this can vary. A plugin could have made changes to your database or files, causing your site to go down. Even your theme could have caused the issue if it includes many features that would better be handled by a plugin.

If your hosting plan is shared or you have a VPS, your hosting company may also have restrictions on the plugins you can install on your site. Activating a prohibited plugin could be enough for your hosting provider to take down your site.

With an internal server error, you won’t be able to access your admin dashboard to deactivate your plugins and themes, but you can still do this manually by accessing your site’s files. You can access your files through your control panel, through FTP or SSH. Use whatever method you’re most comfortable using.

An amendment is made to a plugin folder name.
You can deactivate your plugins by renaming the plugin folders.

In cPanel, go to Files > File Manager and locate your site’s directory. First, deactivate your plugins by temporarily renaming them.

Go to /wp-content/plugins/ and select the first folder on the list, then click the Rename button at the top of the page.

Keep the original folder name intact, but add something at the end such as -deactivated or something similar so you can properly tell your plugins apart later.

Once your plugins are all deactivated, check to see if your site is back up. If it is, you can rename your plugin folders back to the original names one-by-one until your site goes down again. When this happens, that means the last plugin you re-activated was the culprit.

You can also try this with your themes by going to /wp-content/themes/ and renaming your theme folders in the same way you did with your plugins. Don’t deactivate the default WordPress theme so your site has something to fall back on if your site goes up again.

It may also be helpful to upload a fresh copy of the default WordPress theme, especially if you or a hacker made changes to it. You can download a copy from WordPress.org, uncompress it, then add the theme folder through cPanel or FTP.

In cPanel, go to Files > File Manager and navigate to your site and /wp-content/themes/, then click the Upload button at the top to upload the fresh theme file to your site. Don’t forget to click the checkbox on the upload page to overwrite the original theme folder and files.

The cPanel upload page.
You can upload a new theme folder in cPanel.

You can also delete the folder before uploading the fresh copy as well. You can also check out our post How to Use FTP Properly with WordPress for details on how to upload a folder through FTP.

See if your site is back up and if not, you can continue troubleshooting the error.

3. Fix a Corrupted .htaccess File

Another likely cause of an internal server error is a corrupted .htaccess file. Replacing your current one with a fresh copy can save your site and bring it back online.

By now, you should have a backup of your site which is necessary before you replace your .htaccess file, but keeping an extra copy can be useful so you can restore your site quicker if changing your .htaccess file makes matters worse.

In cPanel, go to Files > File Manager and navigate to the directory where your site is held. Click the Settings button at the top of the page and make sure the checkbox to reveal hidden files is checked and enable it if it’s not already checked, then click Save.

In the root of your site, find a file called .htaccess and click on it, then on the Download button at the top of the page. Save the file to your computer.

The inline pop-up in cPanel to create a new file.
You can create a new .htaccess file in cPanel.

Now, create a new .htaccess file. You can do this in cPanel as well, by first deleting your current one.

Click on the file from the list, then click Delete in the file manager menu. Next, click the File button and enter .htaccess for the file’s name, then click Create File.

When your new file shows up on the list, click on it once, then on the Edit button at the top of the page. In the file editor, add the following rules for single installs of WordPress:

For Multisite networks on versions of 3.5 or above and setup with sub-directories, add these rest of rules instead:

If you have sub-domains installed for your Multisite and you’re using the same version, add this to your new .htaccess file:

For all other versions of WordPress, you can check out the WordPress Codex .htaccess page for the rules you should add instead.

Save the file and visit your site to see if this resolved the issue. You can also add any other rules you included one-by-one to see if these changes caused the error.

Also, make sure your changes include proper syntax since a single typo could be the reason your site goes down. Double check any changes you want to include before adding them and saving the file.

4. Increase PHP Memory Limit

You can also try increasing your PHP memory limit if none of the troubleshooting steps so far have helped. The plugins and scripts you use on your site require PHP memory in order for them to load and work on your site.

When a browser requests these plugins and scripts, they load with the help of your site’s PHP memory. Increasing this limit would bring your site back up if this was the cause of the error.

For comprehensive details on how you can increase your memory limit in WordPress can be found in our post How to Increase the Maximum Upload and PHP Memory Limit in WordPress.

5. Verify PHP Version

Sometimes the plugins and scripts you use require a certain or the latest version of PHP to be installed on your server. If you’re using the incorrect version, this could be the cause of the internal server error.

The cPanel homepage with the "server Information" link above the "Switch Theme" section on the left.
Check the version of PHP you’re using to verify that it’s the one you need.

You can check to see what version you’re currently using for your site in cPanel by logging in and clicking the Server Information link on the left-hand side of the page, under the list of stats.

On the page that loads, you should see PHP listed along with the version you have installed.

Look up the plugins and scripts you have activated on your site and check to see if they have special requirements in terms of the version of PHP they need in order to run properly. If you see a discrepancy, you can update your version of PHP or install the version you need.

You can check out the Installation and Configuration page in the PHP documentation for details on how to install and update your version of PHP. You can also check out the Documentation for PHP 4 page for the earlier version of PHP and details on how to migrate to version five.

6. Replacing Core Files

Sometimes, replacing your core WordPress files can fix the error since it could be a syntax issue or improper file permissions. Overwriting these files with fresh copies can revert your site back to what it should be.

You can check out Understanding File Permissions and Using Them to Secure Your Site for details on how to update your file permissions, though, it can be faster to replace the core files through FTP.

You can also check out one of our other posts How to Use FTP Properly with WordPress for details on how to use FTP to replace these files.

It all starts with downloading a fresh copy of WordPress from WordPress.org and saving it to your computer, then uncompressing it. Delete the wp-config-sample.php file and wp-content folder to ensure important files won’t be overwritten since they contain important data for your site.

Then, move all the fresh copies of the core files to your site’s location and choose the overwrite option so you can avoid the extra step of deleting all the corresponding files already on your server.

Also, be sure you do have a full backup of your site before doing this as was mentioned earlier. You don’t want to lose everything when you’re trying to fix your site. That would just plain suck.

Once the core files have been replaced successfully, you can visit your site to see if this worked.

7. Enable Debugging and Logging

At this point, if your site isn’t back up, there’s likely a rare issue going on and you can enable the WordPress debugging mode to troubleshoot further and find the exact issue.

Since enabling debugging also enables front-end error reporting, it’s also important to enable logging so visitors to your site won’t see the extra error messages since they reveal information about your site that could be potentially used by hackers.

To enable debugging and logging while also turning off front-end reporting, add the following to your wp-config.php file above the /* That's all, stop editing! Happy blogging. */ line:

Make sure you don’t already have the debugging line already written in your file. If you do, you can safely replace it with the code above.

It’s important to keep in mind that debugging is not meant for live sites, but when you’re running out of options and your site is down, it can be a helpful tool. Since you’re also turning off front-end error reporting it’s also a bit safer.

Also, don’t forget to delete the debugging code from your wp-config.php file once you’re done or at the very least, change true to false in the define('WP_DEBUG', true); line.

You can also check out Debugging WordPress: How to Use WP_DEBUG for more details on debugging in WordPress.

8. Contact Your Host

If all else fails, contact your hosting provider since they could be already aware of an issue going on with your server. Your host can also let you know if you have used up all your allotted resources as well since this could also cause the error.

If this is the case, all you need to do is upgrade your hosting plan or switch to a different type of plan altogether such as switching from shared hosting to a VPS or from a VPS to a dedicated server.

Plus, on shared and VPS hosting, someone else on your server could be experiencing an issue that ends up leaking over to your site. You can check out Shared, VPS, Dedicated or Cloud Hosting? Which is Best for WordPress? for more details on how this happens.

Your hosting provider can let you know if any of these particular problems are the cause and they can also have a better look to find out the cause of this mysterious error. It may also help to link them to this post so they can have a good idea of what you already tried to troubleshoot the issue.

Scan Your Site for Safety

The internal server error can be a difficult one to solve because it’s a general error that comes up for a whole host of potential problems. Still, these steps can help you figure out what’s causing the issue and also help you fix it to get your site back up.

Once your site is back up, it’s a good idea to scan your site with a security plugin such as our own Defender which is included with a WPMU DEV membership or in our free trial. You could also take a look at other options such as VaultPressWordfence and others.

By scanning your site, you can check to see if a hacker has infiltrated your site and caused the error. Then, you can clean house and remove any instances of the hacker and secure your site. This would also prevent the hacker from coming back again and again.

Also, make sure you also make regular updates of your entire site so you can reduce the number of steps you need to take in case this happens again. It’s easier to just restore your site, rather than trying several different fixes.

You can also automate your backups with Snapshot Pro to save you time as well.

Have you ever experienced the internal server error? What worked for you to get your site back up and running? What are your best tips for troubleshooting and fixing the 500 error? Share your experience in the comments below.