How to Fix the 500 Internal Server Error in WordPress

In WordPress, the Internal Server Error or Error 500 is one of the most annoying errors because it does not return actual data about the underlying issue. It’s hard for beginners to eliminate it. There are many different reasons for Internal Server Errors.

Download WP STAGING to avoid this and other errors in the future. The WP STAGING plugin allows you to create a copy of your WordPress site in seconds. You can test new plugins, designs, and other updates in a secure environment on that staging site.

This error is a very dreaded kind of error. It seems to always come out at a very inopportune time. An error 500 means your site is offline completely and will not be available anymore, meaning you will start losing your customers. If your site is down for more than a few hours, Google might think there is something wrong with your site. This can lead to a loss of your site’s search engine rankings.

In this article, we will try to resolve this error in simple steps. But first, we need to know what the Internal Server Error is to fix it properly.

What is the Internal Server Error in WordPress?

The proper definition of Internal Server Error is unclear or undefined. An Internal Server Error or Error 500 is generic. It occurs when you visit a website, and your program sends a request over to the server where the site is hosted. The server receives the request, measures it, and sends back the resources (CSS, HTML, PHP, etc.) along with a header. If the status code is 200, then it means “Everything is Ok,” but if the status code is 500 (that’s why the name Error 500), there is an error. That error is caused because some code that went wrong on the website end.

The error may look like this:

Error-500

Or it may look like this.

Error 500 - Internal  Server Error

There are many different types of internal server errors with other status codes (500, 501, 501, 502, 503, etc.), but all these status codes are different but similar, so your site ends up not working as expected.

Reason Behind the occurrence of Internal Server Error in WordPress

There are many reasons for this error. In WordPress, mostly, it occurs because of the following issues:

  • Outdated or broken Browser Cache
  • Low Memory Limit
  • Broken code in Plugins and Themes Functions
  • Corrupted files in WordPress core folders
  • Corrupted .htaccess file

How to fix Internal Server Error in WordPress

We have several steps to resolve this problem:

Force Refresh the Page

Press Ctrl + F5 on Windows or Cmd + Shift + R on Mac to force refresh the page. This action bypasses the cached version and loads the most recent version of the website, potentially resolving the error.

Delete the Browser Cache

Another good idea is to clear the browser cache. Clearing the browser cache may solve your problem. How to clear the cache on different browsers are given below:

  1. Google Chrome: Press Ctrl + Shift + Delete, select the desired time range, and click “Clear Data.”
Clear Browser Cache
  1. Mozilla Firefox: Press Ctrl + Shift + Delete, choose the appropriate time range, and click “Clear Now.”
Clear Firefox Browser Cache
  1. Apple Safari: Press Command (⌘) + Option (⌥) + E to instantly clear the browser cache.”
  1. Microsoft Edge (Internet Explorer): Press Ctrl + Shift + Delete, select the desired time range, check the “Cached images and files” option, and click Clear now.
The following steps are more complex and affect the database/files on the WordPress website. To not cause any further damage, and if you still have access to the WordPress dashboard, create a staging site with WP STAGING and try to fix the error on the staging page instead of the production site.

You can create a staging site with WP STAGING.

Check Server Log Files

When your website throws a fatal error 500, you can tell your website to write more explicit error messages into a so-called log file for debugging purposes.

You can  enable the debug mode in your WordPress by opening the file wp-config.php and adding the following lines of code into it:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

You can find the wp-config.php file in the root folder of your WordPress installation. You can use your web hosting control file manager or FTP to edit this file.

Edit Wp-Config File

Check out that article to learn in detail how to activate the WordPress debug.log.

Depending upon what kind of web server your hosting provider uses, you can find the server error log file in the paths:

Apache server: /var/log/apache2/error.log

or

Nginx server: /var/log/nginx/error.log

To access these files, you will need to have full access to your hosting. You can use an FTP client and troubleshoot with the help of these files. Some web hosting control panels also have more easy access to these files.

Check .htaccess File

The 500 Internal Server Error may also happen due to some faulty code in the .htaccess file. That file is located in your WordPress site’s root directory and is essential to make your website running properly.

To troubleshoot your .htaccess, we need to disable the current one and create a new one.

First of all, use FTP or the file manager app in your hosting account to connect to your site.

You can find the .htaccess file beside the folders wp-admin, wp-includes, and wp-content.

Edit .htaccess File
  • Rename the file to .htaccess_backup have a backup of the file if something goes wrong.
  • Please create a new file and name it.htaccess
  • Add the following lines of code into it:
# 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

If the old .htaccess file were the reason for the error 500, this would fix the Internal Server Error for you.

Increase the Server Memory limit.

Sometimes the error 500 occurs because of the low Memory Limit of PHP in WordPress. To resolve this error, you may have to increase the memory limit. If your host provides cPanel, you can increase your PHP memory limit from the dashboard user interface.

The steps are the following:

After opening the cPanel, click on the link that says, “Select PHP version.”

Then, click on “Switch to PHP Options.”

Then, click on “memory_limit” at the bottom and change its value to something higher, usually in the range of multiplied by 2, i.e., 256, 512 and save it.

Another way is to add the line below into your wp-config.php. You can use your hosting file manager software or an FTP client to edit that file.

Edit Wp-Config File

Just add the following line on top of your wp-config.php file.

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

If a lack of memory was your issue, then this step will fix the Internal Server Error for you.

Check Installed Plugins and Themes

Sometimes, an Internal Server Error occurs due to recently installed WordPress themes or plugins. If you recently installed a plugin or theme and it broke your site, there is a chance that you can deactivate that plugin to fix the error.

You can use the step below only if your WordPress admin dashboard under /wp-admin is still available!

  • Log in to your WordPress admin, go to “Plugins,” select the checkboxes for the plugins you want to disable, and choose multiple at once.
    WordPress Dashboard Select Plugins
  • After selecting the plugins, go to the “Bulk Actions” dropdown at the top, choose “Deactivate,” and click the “Apply” button.
    Deactivate plugins to troubleshoot Broken CSS in the WordPress Admin Dashboard
  • Activate the Plugins one by one again and reload your site after each plugin activation.
  • If you see the error again, deactivate or remove that plugin, which causes the problem.

If your WordPress admin dashboard is not available, you can disable a specific plugin by renaming its plugins folder to something else manually.

To do this, connect to your site via FTP.

For instance, if the woocommerce plugin is responsible for error 500 Internal Server Error, you’ll need to rename the folder from
/wp-content/plugins/woocommerce to
/wp-content/plugins/woocommerce-disabled.

After that step, the woocommerce plugin will be disabled, and you can reaccess your website.

If you want to disable all plugins, rename the folder wp-content/plugins and reload your site.

Then all plugins will be disabled, and your site should be reachable again.

After that step, rename the folder wp-content/plugins-tmp back to the original name wp-content/plugins.

Repair WordPress Core Files

Sometimes, especially in older sites, WordPress files can be corrupt. If the WordPress core system is corrupt, you need to repair the core files by replacing them with the original ones.

One way is to go to wordpress.org and download the latest copy of WordPress from there.

  • Once downloading, unzip it.
  • After that, connect to your host using your FTP client or using the file manager within your hosting account.
  • Replace the entire folders /wp-admin and /wp-includes within your WordPress installation with the ones from the extracted zip file.
  • To do that, rename the current folders wp-admin and wp-includes to wp-admin-backup and wp-includes-backup.  This can be done with the hosting file manager or the FTP client.
  • Upload the new directories from the unzipped file to the same location as the old directories.

If your WordPress files were corrupted, this step would fix the 500 Internal Server Error for you.

Contact Your Hosting Provider

There are a few uncommon issues with Internal Server Errors in WordPress. At this point, you have to contact your host. Sometimes, these issues can be resolved by the hosting provider by looking at the file permissions and other settings.

If this still does not solve your issue, You may have to switch to another more optimized host to run your WordPress site.

Subscribe to our YouTube Channel for more WordPress video tutorials and connect with us on Twitter and Facebook.