How to Fix the 500 Internal Server Error in WordPress

How to resolve 500 internal server error

Most of the time, you can have the 500 internal server error solved in 6 steps:

1. Turn on debugging

Whenever WordPress throws you a white screen of death or a server error, I recommend turning your debugging on. While this may not fix the problem, it may give you more insight into what’s going on.

You can turn debugging on by editing your site’s wp-config.php file. Once you’ve accessed this file, search for WP_DEBUG within. If you find it, you should be able to set it to “true”. If you don’t see it in there, you’ll need to create it yourself. Either way, at the end of the day, you should have a line that looks like this:

define( "WP_DEBUG", true );

Once saved, reload your site to see if anything has changed. If you’re lucky, the server error may disappear and might be replaced with a different error, one that actually tells you where the issue is.

If this is the case, take a look at where the error is located. If it is within a plugin folder, disable that plugin, the error should go away.

Even if turning on debugging doesn’t give you a great result, it is a good idea to leave it turned on until the issue is resolved. It will give you and any developers more insight into what’s going on. Don’t forget to turn debugging off once everything is a-ok and you’re done with the maintenance!

2. Deactivate all plugins and switch themes

If you have access to your dashboard, you should deactivate all your plugins and see what’s what. If your website loads without the server error the issue was with one of your plugins. You can switch them on one-by-one to figure out which one caused the issues.

You can also switch your theme to a default, unaltered WordPress theme like Twenty Fifteen or Twenty Sixteen. If the site loads without the internal server error, the issue was within your theme.

I’ve noticed that quite a few of these errors are actually caused by plugins, so this will be your best bet.


Change a WordPress theme in the database

You can activate your WordPress theme from within the database. This is helpful if you can't access WordPress due to an issue with your theme.

  1. Log into phpMyAdmin (cPanel / Plesk / Web Hosting / Managed WordPress).

  2. Click on the database you want to manage.
  3. Click on the wp_options table.
  4. Under the option_name column, locate the template entry. You may need to navigate beyond the first page of entries.
  5. Click Edit next to the template entry.
  6. In the option_value column, change the value to the name of your theme. The new value must be the same as your theme's folder name.
  7. To save, click Go.
  8. Click Edit next to the stylesheet entry.
  9. In the option_value column, change the value to the name of your theme (or child theme, if you've previously created one). The new value must be the same as your theme's folder name(ex. twentyseventeen).
  10. To save, click Go.

3. Check your .htaccess file

The .htaccess file, if it exists, contains a number of rules that tell the server what to do in certain circumstances. It is commonly used for rewriting URLs or preventing access to your site for malicious intent.

Use your FTP editor and check if you have an .htaccess file in your WordPress root folder. You may need to make sure your FTP editor lists hidden files before you do this.

If there is an .htaccess file there, make a backup and then delete all the contents within, or the whole file. This may remove some important rules, but if the internal server error was caused by a mistake within the file, this will tell you.

If the error is now resolved, the issue was with the .htaccess file. Try restoring the file and then deleting blocks of it. If at some point the site starts working, you know which block the issue is in. You can narrow it down to a single line like this usually. You can then remove that line or ask your developer or your host for further assistance.

4. Increase your memory

I’ve never personally run into this issue, but I’ve heard that increasing your memory limit may help – I assume this is more of an issue in shared environments. To get this done, open your wp-config.php file in the WordPress root directory and search for WP_MEMORY_LIMIT. If it exists, change the value to something like “64M”. If it doesn’t, paste the following line into the file:

define('WP_MEMORY_LIMIT', '64M');

If this works then you’ve only solved the issue temporarily. Chances are that you have a faulty bit of code somewhere (which could be a third party plugin) that is exhausting your resources. If your host has monitoring available, take a look at your resource usage with various plugins on/off to get a better idea of what is wasting those precious megabytes.

Comments

Popular posts from this blog

cpanel exam CPSP Answers

How to install zimbra collaboration suite 8.8.11 on CentOS 7

awstats installation