How to fix 500 Internal Server error?

Updated on February 23, 2024

The HTTP 500 Internal Server Error indicates that the server encountered an unexpected condition that prevented it from fulfilling the request. This error response is a generic “catch-all” response. Usually, this indicates that the server cannot find a better 5xx error code to the response.

A status code is a method of informing you of the status of a request. It might be a 200 status code, which indicates that “everything is fine,” or a 500 status code, which indicates something has gone wrong.

If you see a “500 Internal Server Error” message on the browser, something has gone wrong with the website or browser cache. This isn’t a problem with your computer or your internet connection. It’s a problem with the site.

Table of Content:

  1. Causes of 500 Error
  2. Refresh the Browser
  3. Clear Browser Cache
  4. Check Application Error Logs
  5. Error Establishing a Database Connection
  6. Check Plugins and Themes
  7. Reinstall WordPress Core
  8. Permission Error
  9. PHP Memory Limit
  10. Problem with .htaccess File

1) What are the main causes which generate this error?

  • Browser cache.
  • Wrong file and folder permissions.
  • Faulty database.
  • Incorrect database login credentials.
  • Corrupted files in your WordPress installation.
  • Issues with your database server.
  • Corrupted or missing CMS core files.
  • Issues with PHP memory limit or time out with third-party plugins.
  • Issues with third-party plugins and themes.
  • Broken .htaccess file.

2) Refresh the Browser

Some may find this obvious, but one of the simplest and first things you should attempt when experiencing a 500 internal server problem is simply waiting a minute and performing a hard refresh. If the issue is resolved then any server service which got overloaded for a few seconds will comes back to the normal state and the following error will be gone. It is also recommended to check the site in browser incognito mode as well.

3) Clear Browser-Cache

Clearing the browser cache is always a smart first step in troubleshooting before getting into deeper site debugging. To clear the browser cache, select the browser you’re using and follow the below instructions.

  • For Google Chrome:
    • Press Ctrl+Shift+Del from the keyboard.
    • Click on the Advanced tab
    • Time range: All time
    • Check Browser History
    • Check Download history
    • Check Cookies and other site data
    • Check Cached images and files
    • Click Clear data
Clear Browser-Cache for Chrome
  • For Microsoft Edge:
    • Press Ctrl+Shift+Del from the keyboard.
    • Time range: All time
    • Check Browser History
    • Check Download history
    • Check Cookies and other site data
    • Check Cached images and files
    • Click Clear now
Clear Browser-Cache for Microsoft Edge
  • For Mozilla Firefox:
    • Press Ctrl+Shift+Del from the keyboard.
    • Time range to clear: Everything
    • Check Browsing & Download history
    • Check Cookies
    • Check Cache
    • Click OK
Clear Browser-Cache for Mozilla Firefox

4) Check Application Error Logs

There are two ways to check the error(s).

  1. Application Error Log:
    • You can check application errors in the log folder by connecting your application via SSH or SFTP.
    • Once you connect your application via SSH, go to the logs folder of your application.
    • Go to: cd applications/application_folder_name/logs/
    • To view the logs: tail –f error.logs
  1. Print the error on browser:
    • Go to: cd /applications/application_folder_name/public_html
    • Open wp-config.php file and just before /* That’s all, stop editing! Happy publishing. */ edit the below rule:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Now open your website in incognito mode, and you will be able to see the exact error coming on the website.

5) Error Establishing a Database Connection

This error can also occur from database corruption. These are the following reasons due to which this issue comes on the site.

  • The most common issue is the wrong login credentials added to the configuration files. As the incorrect credentials are unable to connect the application with the database, this error shows up. You must ensure the configuration files have the correct database username and password to resolve the issue.
  • The application database can be corrupted either from themes, plugins, or from manual changes made on the database. These plugins and themes also usually constantly add, install, and delete the data from the table. If the information or the table has to be removed, the database would not serve its services. To resolve this issue, you need to consult with your web developer or restore your web application from the backup.
  • There might be corrupted files on the WordPress installation. This usually happens from the corrupted plugins or themes which are used by hackers. You will need to first restore the application on the previous point and then scan the application thoroughly to resolve this issue.

6) Check Plugins and Themes:

  • Plugin Error:

If the error logs show the issue due to a plugin, follow the below tricks.

If you are unable to connect to wp-admin, you still have the option to deactivate the plugin(s) one by one via SSH or SFTP. 

Go to: cd applications/application_folder_name/public_html/wp-content/plugins and rename the compromised plugin. 

Command: mv plugin_folder_name plugin_folder_name-back

Luckily, if you can still access your WordPress dashboard, go to Plugins, select the compromised plugin, and click Deactivate

Now open the site in incognito mode. If the site is working, it means the issue is coming from the plugin, so you will need to contact the plugin’s author or your web developer to look for an alternative.

  • Theme Error:

If the error logs show a theme related, follow the below steps:

Go to: cd applications/application_folder_name/public_html/wp-content/themes and rename the compromised theme or change the current theme with the default theme from wp-cli, then run the following command using SSH.

Command:  wp theme activate twentytwentyone

Now open the site in incognito mode. If the site is working, the issue is coming from the theme, so you will need to contact the theme’s author or your web developer to look for an alternative.

7) Reinstall WordPress Core Files

WordPress core files can become corrupted at times, especially on older sites. It is pretty simple to re-upload the core of WordPress without affecting your plugins or themes. Run the below command after connecting your application via SSH or SFTP.

Go to: cd applications/application_folder_name/public_html/

Command: wp core download skipcontent force

Once the command ran successfully. Then check the site on the browser, and it will open the site.

8) Permission Error

A permissions problem with a file or folder on your server might also result in a 500 internal server error. Here are some common recommendations:

  • All files should be 664 or 660.
    Command: find . -type f -exec chmod 664 {} \; OR find . -type f -exec chmod 660 {} \;
  • All directories should be 775 or 770
    Command: find . -type d -exec chmod 775 {} \; OR find . -type d -exec chmod 770 {} \;
  • No directories should ever be given 777 for security reasons.
  • The wp-config.php file could also be set to 440 or 400 to prevent other users on the server from reading it.
    Command: chmod 440 wp-config.php OR chmod 400 wp-config.php

Note: All the above commands must run inside the public_html folder of the application.

9) PHP Memory Limit

As PHP libraries require a memory limit for the successful execution of PHP scripts. A 500 internal server error might potentially be triggered by exceeding the server’s PHP memory limit. Increasing the available PHP memory limit would be the trick to resolve the error.

There are three different ways through which you can increase PHP memory limit. You can try any of the below method.

  • Increase PHP Memory Limit in Apache

To increase the memory limit on Apache, you can add the following code on the .htaccess file, which is a hidden file present on the webroot path of the application. The default location of this file is the following:

Go to: cd applications/application_folder_name/public_html/

Edit the .htaccess file with your favorite editor and add the below rule at the bottom of the file.

Rule: php_value memory_limit 128M

Mostly it is set to 64M; you can change the value as per the application needs.

  • Increase PHP Memory Limit in php.ini file

If you have root access to your server, you can edit the php.ini file, which is typically located at /etc/php/7.3/apache2. Open the php.ini file, look for memory_limit, and replace the default value 64M to 128M or 256M.

But, most of the time, you do not have access to the php.ini file for security reasons, but you can create it inside the public_html folder.

Go to: cd applications/application_folder_name/public_html/

Command to create: vim php.ini

Rule: memory_limit = 128M

You may also increase max_execution_time in php.ini. By default, its value set to 30. You can increase it to 300.

Rule: max_execution_time = 300

  • Increase PHP Memory Limit in wp-config.php

The final resort is to make the edition on the wp-config.php file, which we do not recommend. But if all the above steps are failed, then you can proceed with this one.

Go to: cd applications/application_folder_name/public_html/

Edit: wp-config.php and add the below rule just before the line /* That’s all, stop editing! Happy publishing. */

Rule: define(‘WP_MEMORY_LIMIT’,’128M’);

If still, the above steps do not resolve the issue, you can contact the support team to further assist in this case.

10) Problem With .htaccess File

Many times, rules in the .htaccess file might also result in a 500 Internal Server Error. This is usually caused by rules pointing to modules that aren’t installed or accessible on the Apache server.

Below are the few steps to resolve the error:

  • Go to: cd applications/application_folder_name/public_html/
  • Rename current .htaccess file
    Command: mv .htaccess .htaccess-old
  • Create a new .htaccess file with your favorite editor
    Command: vim .htaccess
  • Add the below rule:
# 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]
# END WordPress


The 500 internal server problems are always irritating, but perhaps you now have a few more techniques to fix them and get your site back up and running. Remember, PHP timeouts are the most common causes of these sorts of errors.

Need More Help!

Type in your question at the knowledge base website or comment below

Leave a Comment

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