Error Establishing a Database Connection wordpress

WordPress uses two main pieces of technology to provide with its abilities.

  • PHP is a programming language WordPress. The WordPress files have been written in PHP
  • MySQL is a database technology. WordPress uses a MySQL database to store all of website’s content. This includes posts, pages, title of the site, the color settings, etc. MySQL is where every smallest piece of information about the website is kept.

This is where the error occurs when, WordPress cannot access the information in the database via PHP commands. When that happens, WordPress does’nt know what to do next, so it say “Error establishing a database connection”.

There can be reasons why the error occurs. Some of the common reasons are:

1. Incorrect Login Credentials

error establishing a database connection wordpressWordPress needs a specific login and password to access the database. If those change for any reason, then WordPress will no longer be able to bring anything from the database.

2. Corrupted WordPress Files

How To Fix error establishing a database connectionThe core WordPress files can get corrupted as of a failed update among others. This includes things like failed updates of the plugins, themes, and the main WordPress software updates.

3. Corrupted Database

This might result of a rogue plugin messing up the database internally, a hacker’s attack, a theme failing, etc.

4. The Database server is down

How To Fix error establishing a database connectionIn some cases, the web server run on a different machine than the database and that separate database server can be down for whatever reason.

5. Too much traffic

Error Establishing a Database ConnectionThe database might be unresponsive due to high spike in traffic.

How To Fix “error establishing connection”

Step 1: Get in touch with your Web Host Provider

fix Error Establishing a Database Connection wordpressIf the site was working a minute ago or a day ago and now there is a fault that fault can be on web host’s end. All quality hosts offer some form of fast-reacting support, usually through live chat. Most importantly, they will let you know if your database is alright or not or whether any suspicious activity on the server.

Step 2: Check if your Plugin or Theme files haven’t been corruptedHow To Fix error establishing a database connection

  1. Connect to your host via FTP, or can be done with a free tool called FileZilla.
  2. Go into “wp-content” and rename the “plugins” folder to something else.
  3. Go back to your site and see if the error is still there.

Either delete it or go online to see if the solution has been documented.

  • If the error is still there even after renaming the “plugins” folder, go through the exact same process with the “themes” folder.
  • If that doesn’t help, rename both the folders back to “plugins” and “themes”. The error is accused by something else

Step 3: Check if your Database hasn’t been corruptedfix Error Establishing a Database Connection wordpress

  1. Go to your WordPress dashboard.

If you see the same error “error establishing a database connection”, skip that step.

  1. If you see something else, pay attention to what WordPress is suggesting you to do. In the recent version, WordPress has expanded its problem-solving solutions.

One of the possibilities is that you will see a message starting with “one or more database tables are unavailable”. This means that is needs to repair the database.

The repairing is quite simple. First, connect to your site via FTP once again. Go to WordPress root and download the “wp-config.php” file to your desktop.

Now upload the file back to your site (via FTP) overwriting the old version. Once the automatic repair finishes, go back to your site and see if the error is still there.

Step 4: Check Your Database Connection Credentials

define( ‘DB_NAME’ ,  ‘some_db’ );
define( ‘DB_USER’ , ‘some_username’ );
define( ‘DB_PASWORD’ , ‘some_pass’ );
define(‘DB_HOST’ , ‘localhost’ );

Take those four lines mentioned above from the “wp-config.php” file, copy them to the clipboard, contact your web host support again, paste those lines in the chat window and ask if the details are correct for you to be able to connect to your database.

The representative will check everything and come back with some feedback. Most of the time they provide with the correct details in case anything has been changed.

Now take the credentials and put them in your “wp-config.php” file where the old ones used to be. Finally upload the file via FTP. At this stage you can go back to your site and see if the error has been fixed or not.

Step 5: Restore the Default WordPress Files

The easiest way to restore the defaulted files is to just download a clean version of WordPress from and copy it over the one you have right now.

Download the newest package to your desktop. Unpack. Browse through the unpacked archive and delete the “wp-content” folder.

Next, connect to your site via FTP, go to the main WordPress root, upload your new WordPress files. Overwrite all the previous files. When the upload is done, go back to your site.

Explosionweb Solutions is a multifaceted young organization. We specialize in creating top-notch web solutions for your business. We are a team of dedicated and creative professionals continuously working towards making your business realize its true online potential. We have a bold and promising approach to digital marketing, branding, App development and many more online services.