Fix the “Error Establishing a Database Connection” in WordPress Print

  • 0

“Error establishing a database connection”…

…at the place of your beloved website. What a disaster!

Error establishing a database connection

As subtle as a brick!

Admittedly, it’s a scary message! There are no styles, no explanations, just a bare warning straight out of the DOS era. It can be especially frustrating when you encounter the issue without making any changes to the website.

First things first, DEACTIVATE PANIC MODE!

Let me assure you that the problem can be fixed.

It’s an error most WordPress site owners and developers will face at some point in their career.

Outlined in this article, are 5 steps you can take to troubleshoot the “Error establishing a database connection” (A.K.A. EEDC).

(click on the links to navigate the article)

  1. Contact your hosting company
  2. Check database login details
  3. Repair a corrupted database
  4. Create a new database user
  5. Check for corrupted files

Work systematically, and you should be able to restore your website to good operating order in no time!

Understanding the Error

I don’t want to reiterate the obvious, but the error is really self-explanatory – it’s an error establishing a database connection.

In non-technical terms, what exactly does this mean?

To better understand the issue, it’s important to know how WordPress and dynamic websites work. A dynamic website consists of two key parts, those are the website files and database.

 The website files are written in the PHP programming language and make up the WordPress software.

 The database is where all your website’s content is stored. That includes your posts, pages, settings, user data and any iota of information stored on your website.

To render your website, the two parts need to work together.

When a visitor visits a page – PHP code is executed requesting information from the database. The information is retrieved and then displayed to the visitor in the browser.

If for either reason the communication interrupted, WordPress won’t be able to retrieve any information from the database and will return a blank page with an ominous error message.

Common Causes

So why does a connection between a database and website fail? Here are 5 of the most common reasons, accompanied by steps you can take to troubleshoot your website.

 Hosting Problems – There are a handful of reasons why a connection can go south on the web host’s end. For instance, a traffic spike could overload the database and render your website unresponsive. Likewise, they may be updating their hardware or software leaving you temporarily offline.

 Corrupted Files – Your site’s files are made up of the WP core files, plugin and theme files. Often, when a website is hacked or when files are modified, WordPress fails to run correctly and returns an error.

 Corrupted Database – To render your beautiful website, many parts work coherently together. Those are parts are constantly creating, reading, updating and deleting content from the database. It’s rather uncommon, but a hiccup on the backend will return a website error.

 Database User Privileges – Every database has a user that is granted access to create, read, update and delete data. If your database’s user doesn’t have the necessary privileges to fetch data for the website, the website will return an error.

 Database Credentials – Perhaps the most common cause and easiest to resolve is the use of incorrect MySQL login credentials.

Before Fixing

Heads up!

Changes to the database are permanent, that’s why we recommend you make a backup of your database before applying any of the suggested fixes.

Most popular web hosting companies (E.g. SiteGround, Bluehost, HostGator, etc…) use cPanel as their hosting interface. In this article, we’ll also be working with cPanel.

From the cPanel control panel, open PHPMyAdmin.


On the lefthand side, select the database you would like to download and click on the export tab located at the top of the page.

phpmyadmin - databases

The default export method will work just fine. Select SQL as the format and press the go button to start the download.

phpmyadmin - database export

5 Ways to Fix the “Error Establishing a Database Connection”

Without further ado, let’s take a look at 5 different steps you can take to troubleshoot your website.

Note! This guide is written in full transparency. The steps listed below are the ones we would follow if you hired us to fix your WordPress website!

1. Contact your Hosting Company

If you didn’t make any changes to your website and, out of the blue, your website isn’t working anymore. There is a good chance that the issue lies with the hosting company.

In any case, since we are working by process of elimination, it’s a good place to start.

Head over to the support section of your hosting company and initiate a chat session.

You can send them the following message:

Hi Team,

We have an “Error establishing a database connection” and would like to know if you’re having any issues on your end? Perhaps:

i) Traffic spike
ii) DDOS attack
iii) Hardware/software updates


Most good hosting companies will inform you if they are experiencing any difficulties on their end.

If the hosting company is responsible for the downtime, all you can really do is wait for their update.

On the other hand, if you’re responsible for the error, head over to section 2 of this guide.

Tip! Ask the support staff to kindly fix the problem for you! There is a good chance they can restore your website to good operating order

Was this answer helpful?

« Back