What is a 500 Internal Server Error?

The HyperText Transfer Protocol (HTTP) 500 Internal Server Error server error response code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request. This error response is a generic “catch-all” response (Mozilla).

What are the main causes of the 500 Internal Server Error in WordPress?

The corrupt .htaccess file, plugins, and active themes are the common causes of that error. Other possible causes of the 500 error are listed below:

  • The core files of WordPress may be corrupted.

  • Corrupt database.

  • Connectivity problems on the server of the database.

  • The issue with the limit of PHP memory.

  • Cache issue in the browser.

  • Cache issue in the hosting.

Fixing WordPress 500 Internal Server Error

There are multiple methods available for fixing this WordPress Error that are described below:

1. Replacing WordPress Core Files

Access the files from cPanel, create a new folder with any name, like backupFiles, and place all the files in that folder except the wp-content and wp-config files. Then download the latest version of the WordPress core files in zip format from the provided link. (https://wordpress.org/download/). Delete the wp-content folder from the downloaded zip and then create a zip again. Then upload it into the public_html directory and unzip it to replace the existing files with these uploaded files. After replacing all the files, the error will be fixed, and you can access your website.

2. Checking the .htaccess File

The .htaccess file is accessible in the public_html directory of the file manager. Rename the .htaccess file with some random name and create a new file with the .htaccess file name. In that newly created .htaccess file, paste the code that 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

3. Plugins Deactivation

Go to the wp-content folder and rename the plugins folder to any random name, such as plugins-old, then go to your website and refresh the page. Hopefully, your website will work again. Now open wp-admin and go to the plugins tab. Then access your file manager again to rename the plugins folder to plugins. After that, go back to your wp-admin and refresh the plugins tab, where you will see all of your plugins, but all of them will be disabled. Now activate these plugins one by one to identify the faulty plugin that is causing the internal server error.

4. Theme Deactivation

Identify the active theme by checking the value of the stylesheet and template in the table of wp-options in the database. For example, if its value is twentytwentytwo then TwentyTwentyTwo is the active theme of WordPress. Then you need to rename the active theme with any random name by accessing it from the theme folder in wp-content. After that, download a new theme, such as TwentyTwentyThree, and then compress it into the zip format. Then you need to upload the file into the wp-content folder and also unzip it. Finally, change the value of the stylesheet from twentytwentytwo to twentytwentythree for the activation of the new theme.

5. Increasing the PHP Memory Limit

Edit the wp-config.php file that you will find in the public-html directory of the file manager. Then add the code “define( ‘WP_MEMORY_LIMIT’, ‘512M’ );” for increasing the limit. Another way is to edit the .htaccess file, which will also be available in the public_html directory. Just open it and add a few lines of code like “php_value memory_limit 256M” which will increase the PHP memory for fixing the issue. You can also do this in php.ini. Here is the php.ini I use

memory_limit = 512M
upload_max_filesize = 512M
post_max_size = 512M
file_uploads = On
max_execution_time = 360
max_input_time = 1000
max_input_vars = 3000

The recommended way to change the limits is

Open the cPanel and go to the “Select PHP version” tab or “MultiPHP INI Editor”, select the domain, and then click on Options and scroll to the bottom. Here you will see the limits of your hosting. Change these limits to the maximum.

Elementor 500 error memory limits in cPanel

6. Changing PHP Version

Sometimes changing the version of PHP also solves the error, like if you have an 8.x version, change it to 7.4, or sometimes changing from 7.4 to 8.x can also resolve the issue. You can change the PHP version from cPanel by accessing the “Select PHP Version” tab.

Changing PHP Version using .htaccess file

If you don’t have access to hosting, you can also change the PHP version in the .htaccess file Here is the code:

<IfModule mime_module>
AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>

7. Database Connection Error

Sometimes credentials errors in the database also show a 500 internal server error. There are four basic credentials: the database name, database user, hostname, and password. You need to cross-check the credentials that you have written in the wp-config file. You can check the database name and database user from the MySQL Databases tab in the cPanel. Retrieve the hostname from the hosting account; usually, the DB_HOST is localhost. Finally, if you don’t even remember the password, you can change it from the MySQL Databases tab that is accessible from the cPanel. Just enter the correct credentials in the wp-config file to fix this error.

8. Clearing the browser cache

The browser cache can be cleared by accessing the clear browsing data option from the more tools menu in the settings of the Chrome browser. Settings may be different depending on the browser you use.

If you are still facing any issues with your WordPress Website you can Hire Me on Fiverr or email me at: contact@ammarafzal.net

Tagged With:

Leave a Reply

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