How to Fix a 500 Internal Server Error

The 500 Internal Server Error: What it is, and How to Fix it

One of the most panic-inducing issues you might encounter on your WordPress website is the 500 internal server error. It can appear on any page of your website when there’s something wrong with your site’s file system or its server. Whatever the cause in your case, the outcome remains the same – your site will be offline, for all to see.

Thankfully, there are a number of ways you can troubleshoot your WordPress website, even before knowing exactly what caused the problem. Often, something as simple as deactivating themes and plugins or creating a new .htaccess file will do the trick.

In this post, we’ll go into depth on what the 500 internal server error actually is, then offer a step-by-step process on how to troubleshoot it. Let’s get cracking!

What Is the 500 Internal Server Error?

500 internal server errors aren’t specific to WordPress alone. In fact, they’re a common server-side issue that points to something being wrong with your website’s server. To put it simply, the error can arise because of a fault with other sites, services, or software running on the same server as your WordPress site.

Despite the error message not being particularly detailed, the root cause can often be narrowed down to one of the following reasons (although they’re not the only ones):

  • Corrupted .htaccess file: The .htaccess file is a WordPress core file used to determine how Apache serves files from its root directory. Messing around with the .htaccess file can lead to it becoming corrupted.
  • PHP memory limit exceeded: The plugins and scripts you use require PHP memory to work. Exceeding – or approaching – your limit can trigger the 500 internal server error.
  • Improper file permissions: When your site’s core files have improper file permissions, it can lead to all kind of errors (and security vulnerabilities).

In some cases, the 500 internal server error will affect your entire site, but sometimes it’ll only appear when a user tries to access the WordPress admin login screen. Either way, since the error has several potential causes, it’s important to go about troubleshooting it systematically.

How Can I Fix the 500 Internal Server Error?

Before we roll up our sleeves, we need to get our tools in order. Since you’ll be dealing with WordPress’ core files, we strongly recommend that you create a backup of your site before starting. The free UpdraftPlus backup plugin is a great tool for this task, and you should also consider VaultPress if your budget allows for it.

Furthermore, you’ll need an FTP client for this section – we recommend Filezilla. If you don’t have your FTP login credentials handy, you can usually get them from your hosting dashboard.

Step #1: Deactivate Your Themes and Plugins

Plugins can sometimes make changes to your site’s database or core files, which in turn may trigger the 500 internal server error. Themes that require plugins to implement certain functionality are no different.

As we mentioned earlier, sometimes the 500 internal server error affects an entire site – while in other cases only the login page is affected. If you’re still able to access your WordPress login page then you can always deactivate your themes and plugins via the admin panel.

On the other hand, if your entire site is afflicted with 500 internal server error then we need to get a bit more creative. Fortunately, you can still get the job done by accessing your site’s files through the cPanel or an FTP client. To accomplish the latter, log in to your FTP client and navigate to the public-htmlwp-content > plugins folder:

Plugins folder

You can deactivate the plugins by temporarily renaming each of them. Simply right-click on the plugin’s name and click on Rename:

Rename menu item

We find that it’s best to keep the plugin’s original name mostly intact, to more easily keep track of which plugins are deactivated. To exemplify, we’ll append the string -isdeactivated to ours:

Renamed plugin

Now, go ahead and deactivate all your plugins, one by one. Once that’s done, check to see if the error has disappeared. If it has, then it’s safe to assume a plugin was behind the problem. With that solved, return each plugin to its original name, and check your site after each re-activation. When the error pops up again you’ll know exactly which plugin was causing the problem.

By applying the same process to your installed themes, you’ll be able to restore your site in no time – assuming that the issue was either a theme or plugin. If this step didn’t do the trick, continue reading – or do so anyway, since knowing this stuff will come in handy!

Step #2: Create a New .htaccess File

Another likely cause of the 500 internal server error is a corrupted .htaccess file. The .htaccess file determines how Apache serves files from your WordPress site’s root directory. Even if you haven’t messed around with the file’s code it can still become corrupted because of – you guessed it – plugins.

To remedy this issue, all you have to do is replace the original .htaccess file with a brand new one. To get started, log in to your FTP client and find your site’s .htaccess file, which should be located right in the root directory:

.htaccess file

Proceed to delete the .htaccess file from your WordPress site’s root directory. Afterward, create a new file by right-clicking and selecting the Create new file menu item:

Create new file

Now name that new file .htaccess and confirm your choice:

Filename

Finally, open the file using a text editor and add the following code:

# 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

Click the Save button to continue. Now, head over to your site and check if the error persists. If it does, then move on to step number three.

Step #3: Increase the PHP Memory Limit

Every plugin and script that your site uses requires PHP memory to load and function properly. This means that when a browser requests any of these resources, it’s going to call upon your server for the necessary files. If it runs out of available PHP memory, then you could encounter a 500 internal server error.

To increase your PHP memory limit, log in to your FTP client and locate the wp-config.php file on your installation’s root directory:

wp-config file

Open wp-config.php using a text editor and add the following line of code right after the <?php tag:

define(‘WP_MEMORY_LIMIT’, ‘64M’);

Then save the file and try accessing your site once more. It’s worth noting that 64MB isn’t the highest that you can set your PHP memory, but it should be enough in most cases.

Some hosts won’t let you modify this setting manually (or at all), in which case you’ll have to ask them to do so for you.

If you’re still encountering the error after doing all of the above, then it’s time to bring out the big guns and replace your WordPress installation’s core files.

Step #4: Replace Your Site’s Core Files

Replace the core files on your WordPress website can be especially effective if your problem has to do with improper file permissions or syntax issues.

To get started, download a new copy of WordPress and uncompress the file on your desktop. Afterward, delete the following files from the folder to ensure you don’t accidentally overwrite the rest of your site:

  • The wp-config-sample.php file.
  • The wp-content directory.

Now, copy and paste the remaining core files to your site’s root directory through the FTP client. Choose to overwrite the existing files when asked. (This way you won’t have to manually delete the existing core files and risk deleting anything extra.)

FTP file explorer

After that’s done, try accessing your site again to see if you succeeded in fixing things. Otherwise, we’ll need to get a bit more creative.

Step #5: Enable Debugging and Logging

If you made it to this step, then your site is facing a rare problem. As a last resort, you can enable WordPress’ debugging mode, which should provide you with more clues. Start by logging in to your FTP client and open your site’s wp-config.php file using a text editor.

Above the line that reads /* That’s all, stop editing! Happy blogging. */ add the following lines of code:

define('WP_DEBUG', true);

define('WP_DEBUG_LOG', true);

define('WP_DEBUG_DISPLAY', false);

@ini_set('display_errors', 0);

Adding this code will enable debugging and a corresponding log for your site. Using the WordPress debug log can provide you with a great deal of information while debugging in WordPress.

Conclusion

There aren’t many issues more debilitating for a WordPress website than the 500 internal server error. However, by troubleshooting the error systematically, you should regain full control over your site in no time.

Here’s a recap of the five steps you need to remember to troubleshoot the 500 internal server error effectively:

  1. Deactivate your themes and plugins.
  2. Replace your .htaccess file.
  3. Increase your site’s PHP memory limit.
  4. Replace your WordPress core files.
  5. Enable the WordPress debug mode, in case all of the above fail.

Do you have any questions about troubleshooting the 500 internal server error in WordPress? Let us know in the comments section below!

This post may contain affiliate links, which means Nimbus Themes may receive compensation if you make a purchase using these links.

Leave a Reply

Your email address will not be published. Required fields are marked *