Error Establishing Database Connection

How to Fix Error Establishing Database Connection in WordPress

Having a problem Fixing Error Establishing Database Connection with the WordPress database? This error may happen because of many reasons and sometimes it’s very frustrating to fix this error. We got this same error few days ago on our own site and It took a little over 10 minutes to detect and fix the problem. Sometimes a bad plugin might be a nightmare.

Error Establishing Database Connection

I used below techniques to fix this error establishing a database connection in WordPress.

Why you’re getting this Error Establishing Database Connection?

We encountered this error because WordPress is incapable to reach the database.

This may happen because of the following reasons:

1. A bad plugin corrupts the database.
2. Wrong Credentials on the wp-config.php file. Wp-config is a PHP file that we can easily edit with FileZilla.

3. The website has been moved to a new web host.

Let’s discuss all the reasons one by one.

1. A bad plugin corrupts the database.

To troubleshoot this error, we’ve to find the problematic plugin. Go to plugins and click Installed Plugins. deactivate the WordPress plugins one by one and find the problematic plugin.
For this purpose, go to the Admin Dashboard and from the Left side bar click Plugins. Follow this: Dashboard > Plugins > Installed Plugins. Here you will find all Installed plugins. Deactivate the plugins one by one and keep checking your website until you find the problematic plugin.

Error Establishing Database Connection

Now, reload your website to check if the database connection error is fixed. If it is fixed then that would be great, but if not then navigate to the next step.

2. Wrong Credentials on the wp-config.php file.

The most common reason is the “Wrong Credentials on the wp-config.php file.” For this purpose, we’ve to open the wp-config.php file and check the Credentials there.

To check the credentials of the website, I’m going to use FileZilla. If you don’t have this software yet, I’d like to suggest you installing it. FileZilla is a very handy tool to access and edit the files.
Open FileZilla and connect your server. Find wp-config.php file and open the Root directory of your WordPress host through FileZilla. Right click and edit this wp-config.php file.

Error Establishing Database Connection

Open wp-config.php file and make sure that credentials are correct. If Database credentials are wrong, then fix them.

Ideally, at this point, the issue has been settled. If not, move to the following step.

3. The website has been moved to a new web host.

This error may occur because you changed your webhost. You’ve to use the same above process. Open the wp-config.php file and update the new WordPress database credentials.

If you’re unable to fix this, then Contact your new webhost and ask them to fix this issue.

Leave a Reply

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