How to Fix the Error Establishing a Database Connection in WordPress?
Error Establishing a Database Connection

02/04/2022 by admin with 0 comments

“Error Establishing a Database Connection” in WordPress

In one way or another, you will come across this while browsing on WordPress. Well, today we gonna know how to fix this. Before undoing this error, we need to unveil quite a few possibilities causing this issue and in order to do that, we know to be acquainted with a few terms.

WordPress is a service provider site. It can be accessed and have two different URLs fulfilling different purposes, namely and WordPress mainly provides you a platform for bogging as well as provides you with well-furnished websites relating to any work.

The basic difference between both the URLs is that is a purchasable software, so that the user can own and self host the website whereas is handled by the web server’s owner that is WordPress only, basically they do all the tasks for you. It’s much easier to create a website on because it comes with fewer technical liabilities.

What does Database Connection in WordPress mean?

The error occurring in the Database Connection is a kind of the info affiliation error, it primarily means that the PHP Code was enabled to form a connection with the MySQL database. This connection is necessary to retrieve and access the data from the database so that a successful connection is created and if in any case this procedure is not completed, the user sees the message “Error Establishing a Database Connection”.

What causes the error in Database Connection in WordPress?

The causes for error in the Database could range from entering the wrong credentials for the password or username to. Secondly, MySQL is a database that is kind of prone to errors, so the errors might be caused in the MySQL database because some data is found missing or some has tempered data in the MySQL database, due to which a secure connection cannot be established.

Thirdly, the data is stockpiled to form files that have all the information about the making of the website and if any falsification is identified, then the secure connection is hindered. Lastly, any issue that comes along with your host, while you are self-hosting and then WordPress hits database up for that information and if the database does not revert back, then also data connection is not established.

How can we fix “Error Establishing a Database Connection” in WordPress?

The problems discussed in the above paragraph will now be fixed. So, here we go

Step 1: Examine Login Details

To check your credentials, you are provided access to the file (wpconfig.php) and in order to ingress this file, you could utilize SFTP (Secure File Transfer Protocol) client.

Tally your username and password, if it does not go with the entered information, then change it and fill in the correct details.

However, if the case arises that your username is correct but the password is having some issue then update that information on the User Details screen.

Step 2: Purging the Corrupted Database

As we talked about the MySQL database could have bugs, in this step we are going to look for the steps that help us to check that.

If you entered the correct login credentials and still are seeing this same error then visit your WordPress website’s dashboard and visit the following URL.

If still the error persists look and carry on with the WordPress suggestions, the updation of WordPress now suggests steps to follow, if you come around any error.

Sometimes a database is required to be mended, but for that also error pops up.

Step 3: Examine the Information of your Database Host

Database Host is basically a database server, they are used to run the website’s server properly. After you have gone through the above two mentioned steps and still cannot find any issue then you should look into the database host information.

Generally, websites use ‘localhost’, but in some cases of WordPress, you might need to ask WordPress’s support team about your website’s database host information.

Localhost is the hostname that can be found in the MySQL database. You can look for it in the system’s files layout. And if you see any issue in that you could go ahead and update its credentials.

Step 4: Inquire into Database’s Server

Sometimes, the database’s server (MySQL) is down due to which this issue might be occurring, so you should check into this too.

Significant heavy traffic on the server might cause this problem. Generally, if you have opted for shared Hosting you might find this issue because the server simply is unable to handle even a few users.

Check if you have got a different number of websites running on a single server.

Another step that you could follow is to try and get access to ‘phpMyAdmin’, for this you have to go to your ‘hosting dashboard’ and then only you get access to that file.

Try connecting to the database and as soon as you will connect, then you have to get your user examined for adequate permission.

Then, produce a replacement file known as testconnection.php and paste the subsequent code into


                  $link = mysqli_connect(‘localhost’, ‘username’, ‘password’);

                    if (!$link) {

                   die(‘Could not connect: ‘ . mysqli_error());


                   echo ‘Connected successfully’;



If the code works properly, there you will be able to resolve this problem

Step 5: Revive or Reboot the webserver

Users on their native servers and also on VPS (Virtual Private Server) should attempt for reviving their web servers.

This can revive your whole database, by repairing glitches inflicting the server.

Step 6: Upgrade your URL of WordPress’s Site

Click on the ‘Hosting account’ on your dashboard.

From the hosting account, select ‘phpMyAdmin’.

Click on the WordPress database.

On the top, you will see a bar, select ‘SQL Menu’ from there.

Enter the subsequent query in the given space. UPDATE wp_options SET option_value=’YOUR_SITE_URL’ WHERE option_name=’siteurl’

In the above query you have to make a few changes, i.e. to write your ‘table name’ in place of ‘wp_options’ and also write the URL of your choice in place of ‘your_site_URL’.

Lastly, you could contact your web hosting company and get your issue resolved.

Leave Comment