How to fix Internal Server Error in WordPress

How to fix Internal Server Error in WordPress


It is the most common error in WordPress. It does not give any information about the error. For developers, it will be easy to fix it but for non-technical or beginners it will be a bit of a challenge. In this article, we will show how to debug and solve internal server error.

Cause of Error

Internal Server Error not only appear in WordPress but I can happen in any website. Due to generic nature of this nature, it will not give any information, so we need to use different methods so sort out the issue.

Internal Server Error

Below are a few methods for troubleshoot the error.

.htaccess file

First step is to check your .htaccess file. It is located in the installation folder of WordPress. Same place where wp-admin & wp-content folder is placed. Try to rename the file to .htaccess-old and refresh the page, if it solve the issue then go to dashboard->settings->permalinks and update the permalink. It will generate the new .htaccess file. Another method you can use by changing the .htaccess code. Put the code in .htaccess file which is given below.

# BEGIN WordPress

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Make sure you renamed the file back to .htaccess. if this method does not solve the issue then we need to try another method.

PHP Memory Limit

Sometimes the internal server error appears when you are trying to upload a large file that may exhaust the memory limit. WordPress default memory limit is 32MB. There are three options you can use to increase the memory limit.

Edit your wp-config file: This file is located in root folder of WordPress. Look for the line to edit the memory.

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

Increase the limit as you want, 128M should be enough.

Edit your php.ini file:  If wp-config file does not solve the issue, then you need to go through the server settings. On shared hosting you cannot access the php.ini file. This is what you need to do:

  1. Find php.ini, if you cannot find it the create your own php.ini in WordPress root folder and save it.
    1. Open file in text editor.
    2. Find the line that says ‘memory limit = 32M’.
    3. Change 32MB to desire limit.
    4. Restart server after save the changes.

If you create your own php.ini file, you need to add the following line:

memory_limit = 256M

Edit your .htaccess file: If you cannot access the php.ini file then you need to edit your .htaccess file. It is located in the root directory of WordPress installation. Below are the code you need to add in your .htaccess file.

php_value memory_limit 256M

Turn on Debug

You can turn on error log in WordPress in just a few steps.

In wp-config file, You might see the following line of code:

define(‘WP_DEBUG’, false);

delete it and copy the following line of code:

Make WordPress debug enable:

define(‘WP_DEBUG’, true);

All the errors will be saved in debug.log. You can find this file in wp-content folder.

define(‘WP_DEBUG_LOG’, false);

To display error messages on screen add this line of code:

define(‘WP_DEBUG_DISPLAY’, false);

Save your changes and debug mode will be turned on.

Deactivate All Plugins

If increasing the memory limit will not solve the error, then you need to deactivate all the plugins. If internal server error is resolved by doing it then activate the plugin one by one until you find which plugin is causing the issue and remove that plugin.

Re-Upload Core Files

If error still exist then re-upload the core files of WordPress, which includes wp-admin and wp-includes, you will not lose anything by uploading the files. This could be an issue if a virus has altered the WP core files. In which case, you may have bigger fish to fry.

Ask your hosting Provider

If all given methods fail then you need to ask your hosting provider to look at server logs and find the root cause of the error.

We hope this article will help you to debug the internal server error on your website. If you have WordPress 500 error then you can discuss it with a WordPress Expert.