The 500 Internal Server Error in WordPress occurs when there is a problem with the server or file system that is powering your site. The cause is most likely to be found in the root directory of the site, where you store your WordPress files. At the same time, it can also be caused by a problem on your host’s server.

The Internal Server Error is one of the most frustrating problems that can occur in WordPress because there is never a solution that can be just taken out of the box. Solving the problem usually takes up quite a lot of time and energy.

Precautions

Before you begin addressing the Internal Server Error it is necessary to make a copy of your WordPress database and backup your site. You can find detailed instructions on how to do that in the WordPress Codex: https://codex.wordpress.org/WordPress_Backups or use one of the several plugins that automate the process for you.

The .htaccess file

One of the two most frequent causes for the 500 Internal Server Error is a corrupted .htaccess file. The .htaccess file could become corrupted while you made a change to your WordPress site or possibly by uploading a poorly written plugin to the site directory. In order to fix this, you will need to restore the .htaccess file.

The .htaccess file contains the rewrite rules that are necessary for your WordPress site to work properly. If you have access to the admin panel of WordPress, the first option to amend the .htaccess would be to reset the permalinks structure of WordPress. Go to the “Settings” and then “Permalinks” tab on the dashboard and choose some other permalinks option from the one currently in use. Hit “Save Changes” and WordPress rewrites the .htaccess file and “resets” it. Now you can revert to the original permalinks setting and save the changes again.

If this does not solve the Internal Server Error or you do not have access to the admin area another option is to restore the .htaccess file through FTP server access. If you do not know how to use an FTP server, please find a good tutorial here.

Now you need to create a new file in Notepad (Windows) or Text Edit (OS X) and name it as “.htaccess”. You may need to enable the option to show hidden files in order to see the file after it has been created. The reason is that any files starting with a “.” are treated as hidden files. Open the file up and paste the following 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

It is very important that you leave no blank lines above or below the text. This is the content of the default .htaccess file that is created with a fresh installation of WordPress. Now you need to login to your WordPress installation through the FTP and first rename the existing .htaccess file (for example, to .htaccess_old) as a backup and then upload the new .htaccess file to the same directory.

After you have established that the .htaccess was the culprit and that now your site runs smoothly, you should go to the Settings – Permalinks in your Admin area and click „Save“. This will generate a new .htaccess file for you with correct re-write rules and ensure that your posts and pages do not return a 404 Error.

Exceeding the PHP memory limit

Another common reason for the 500 Error is exceeding your server’s PHP memory limit. Again this might have been caused by a poorly written plugin that takes up too much memory or simply by the fact that over time your site has expanded so much that it simply exceeds the limit provided by your server’s host.

WordPress also limits the PHP memory and does so in the wp-config.php file. This can also be found in the root directory through the FTP. You need to download the file and open in a text editor. Now add this piece of code under the opening PHP tag:


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

Save the file and upload it to the root directory, replacing the old wp-config.php file. Refresh the FTP client and your site in the browser. If you still see the Internal Server Error, remove the code, hit save and re-upload the file again to the root directory.

Other solutions for the 500 Internal Server Error

1. Deactivating plugins to check if any of them are faulty plugins.

In the WordPress admin area, deactivate your plugins one by one. You have to refresh the site after each deactivation. As soon as the error disappears, you will know that it was likely caused by the plugin you deactivated before refreshing. The only solution is to replace the plugin with another one that has the same functionality. Alternatively, you could contact the plugin authors and let them know of the error it has caused and ask them to make amendments.

2. Debugging your site.

WordPress has a built-in debugging feature. Debugging is enabled by pasting the following code to the wp-config.php file and replacing the existing wp-config.php in the root directory.

define( ‘WP_DEBUG’, true );

define( ‘WP_DEBUG_DISPLAY’, false );

define( ‘WP_DEBUG_LOG’, true );

Any errors found or the debug log is saved in a file called debug.log in your site’s content directory.  Usually you would need expert help in deciphering the error log and fixing problems with it’s help. Look around the web for advice.

3. Checking if files and folders have the correct file permissions.

In your WordPress directory, permissions for folders and files should be 755 or 644. If the permissions have been set to anything else, it may cause problems, including 500 internal server errors. Again, you can check the permissions through the FTP client and they are usually shown in the Permissions tab.

4. Uploading fresh wp-content and wp-includes folders to your site.

First back up your site as a precaution. Then locate the same version of WordPress your site is currently using at the WordPress.org repository and download it. Find the wp-content and wp-includes folders in the download and replace them in your WordPress directory, overwriting the old ones. Refresh the client and the site – if the error is gone, it was most likely caused by a corrupt core file.

5. Looking at the error logs.

If the error still persists there is no other option than contacting your server host and asking them if the issue is on the server that powers your site. The error logs for your server can provide valuable context related to any code failures or other potential causes of a site failure.

6. Avoiding problems in the future

Be sure that your site and plugins are updated on a regular basis.

Also, try to find a reliable hosting provider. Sometimes the low-budget services are not the best solution. Before you choose a provider, look around in forums and user feedback to determine if there are any shortcomings in the quality of the service.

Subscribe to our mailing list

Signup today for free and be the first to get notified on new updates.

Leave A Comment

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