How to Resolve 500 Internal Server Error

Here’s how you can resolve 500 Internal Server Error on your WordPress website [With Code example].

Cloudways Product avatar
Written by Cloudways Product
Updated over a week ago

The 500 Internal Server Error is perhaps the most annoying error you can encounter. In many instances, you can easily resolve the issue by applying the process outlined in this KB.

In a 500 Internal Server Error situation, the server has encountered an unexpected condition that prevents it from fulfilling the clients’ requests. Note that essentially, there is nothing wrong with the server itself. It has simply encountered something it can’t figure out.

Important

Before making changes to the site’s code and database, it is always a good practice to take a full backup of the server, so that you can restore the site in case something goes wrong.

Resolving 500 Internal Server Error requires you to follow this process:

How to Resolve 500 Internal Server Error

Step 1: Debugging the Issue

The first step is to make sense of the situation and try to make sense of the error. For this, you need to check PHP logs (part of Apache error logs) for more information about the error.

If you are unable to find the error logs there, try enabling PHP error reporting by adding the following lines to the index.php file:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

If you have a WordPress website, download the wp-config.php file (located in the website’s root directory) via SFTP and open it in your preferred text editor. Search for the string ‘WP_DEBUG’. If you find the line, simply change FALSE to TRUE and upload the file again.

If the line isn’t in the config file, add the following line to the wp-config.php file:

define( "WP_DEBUG", true );

Reload the website and see if the error changes.

If it does, and you now see a ‘fatal error’ message that points to a specific line of code in a specific file, you’re looking at a relatively simple code error. Assuming that the said error originates from a plugin or theme, you’ll need to disable the offending product and/or work on fixing the issue yourself (or have someone else take a look at it if you’re not able to work out what’s happening on your own).

Important

Once you have found the problem, remember to change the above-mentioned ‘TRUE’ value back to ‘FALSE’ within the wp-config.php file.

Step 2: Empty .htaccess File

An empty .htaccess file can also cause this error on all the internal pages. Therefore, add the following rules in your .htaccess file by remotely connecting to your server using SSH/SFTP.

# BEGIN WordPressRewriteEngine 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

Step 3: Debug .htaccess Issues

In many cases, rules in the .htaccess file can also cause 500 Internal Server Error. This is generally caused by rules that point to modules that are not installed/available at the Apache server.

Another scenario involves recursive rewrite rules that can end up in a 500 Internal Server error.

Step 4: Increase PHP Memory Limit

PHP libraries require a memory limit for the successful execution of PHP scripts. Increasing the available PHP memory limit from the Server and Packages tab can also fix the 500 Internal Server error. If you have defined a memory limit in the application configuration files, simply increase the value in these files. Changing the PHP memory limit will also help you avoid the “Allowed memory size” error.

Step 5: Check if the Admin Works

Log in to the admin panel for your website. If this page loads properly and allows you to log in, you can be reasonably sure that the issue is with a plugin/extension/module or with the active theme. If the admin page loads, move on to Step 4.

Step 6: Revert Recent Changes

If your dev team pushed changes just before the 500 error was reported, you should try to revert back to the last available version. This way, you could eliminate a very probable source of the error.


It is always a good practice to test the changes on a staging website/environment to make sure everything works as intended. To help our users, the Cloudways Staging feature provides dedicated and unlimited staging sites where they can test website changes before pushing code to live servers.

Step 7: Audit Your Plugins/Extensions/Modules

Plugins/extensions/modules can also cause 500 Internal Server Error. In general, the error occurs because of the compatibility issues caused by outdated plugins/extensions/modules or poorly coded new ones. In this context, you might encounter the error after installing a plugin/extension/module.

To find out which of your plugins/extensions/modules is causing the error, deactivate ALL of them and then reactivate them one at a time. For WordPress, Magento, and similar apps, use the application Dashboard, CLI or SFTP.

If you discover the offending plugin/extension, deactivate (or better yet uninstall) it and get in touch with the developer for help.

Step 8: Check File Permissions

If none of the above works, the issue can lie with file permissions. Fortunately, the fix is simple: Simply hit the Reset Permissions button.

That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.


With Cloudways’ optimized configurations and proactive server management, you can get rid errors like 500 internal server error for good. Choose our WordPress hosting server and experice a seamless managed hosting environment.

Did this answer your question?