← Repair Hub

Error Establishing a Database Connection

SSL, Security & Connection

Your site is fine. It just can't reach the place its content lives.

datacram.com/fix/error-establishing-database-connection
Likely causes, ranked
Error Establishing a Database Connection
The database server is down or overloadedmost likely
Wrong credentials in the configcommon
Too many connectionscommon
A corrupted database tablepossible
Fix steps in this guide5
the causes explained below, most likely first
What you’re seeing

A plain white page with a single line of text: “Error establishing a database connection”. No design, no navigation, no admin. Sometimes it comes and goes with traffic.

What it actually means

Your site is two things: code that decides how pages look, and a database holding the words and prices inside them. This error means the first cannot reach the second. The files are intact. The content is almost certainly intact. The conversation between them has stopped.

That distinction matters because the error looks catastrophic and usually is not. In most cases nothing has been lost. Something between the application and the database — a credential, a service, a resource limit — has changed or run out.

What usually causes it

Most likely first.

  1. 1

    The database server is down or overloaded

    Especially on shared hosting, where a neighbor's traffic can exhaust the database service. Typically intermittent rather than constant.

  2. 2

    Wrong credentials in the config

    A host migration, a password rotation, or a restored config file pointing at the old database name, user, or hostname.

  3. 3

    Too many connections

    Traffic or a runaway process opened more connections than the limit allows. New requests are refused until some close.

  4. 4

    A corrupted database table

    Usually after an unclean shutdown or a disk problem. The connection works but a table cannot be read.

  5. 5

    Disk full

    A database that cannot write cannot serve. Log files and backups quietly fill a disk more often than anyone expects.

How to fix it

Work through these in order. Take a backup before you change anything.

  1. Step 1Check the host status and resources

    Look at the hosting dashboard for database service status, disk usage, and connection counts. If the error is intermittent and tracks traffic, it is a resource ceiling.

  2. Step 2Verify the credentials

    On WordPress, confirm DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST in wp-config.php match what the host shows. DB_HOST is not always localhost on managed platforms.

  3. Step 3Test the connection independently

    Open the database in phpMyAdmin or a client with the same credentials. If that fails too, the problem is the database or its credentials, not your site's code.

  4. Step 4Repair the tables

    If the connection works but pages still fail, run a repair. WordPress has a built-in repair mode you enable temporarily in wp-config.php — turn it off again afterward, since the page is public while it is on.

  5. Step 5Restart or ask for a restart

    If the service is stuck, restarting the database clears hung connections. On managed hosting, this is a support ticket rather than a command.

When to stop and call someone

Call someone if repair mode does not restore the site, if the error returns every time traffic rises, or before restoring from a backup — a bad restore on top of a partly working database can turn a recoverable outage into genuine data loss.

Frequently asked

It means your website's code cannot reach the database that stores its content. The files and the content are usually both intact — what has failed is the connection between them, whether through wrong credentials, a stopped service, or an exhausted resource limit.

Almost never. The error is about reaching the database, not about its contents. In the large majority of cases the data is sitting there untouched and returns the moment the connection is restored.

That pattern points to resources rather than configuration. When the database hits its connection limit or the server is overloaded, some requests are refused and others succeed. Wrong credentials, by contrast, fail every single time.

They live in wp-config.php in the site root: DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST. Compare each against what your hosting panel shows. DB_HOST is a common trap, because managed hosts often use a specific hostname rather than localhost.

Not as a first move. Restoring can overwrite good data with older data and turn a connection problem into real loss. Diagnose the cause first — credentials, service status, disk space — and treat a restore as the last option, after taking a fresh copy of the current state.

Free · AI-powered · Emailed to you

See exactly what’s holding your website back.

Get a free audit of your site — speed, SEO, mobile, and security — with the fixes that matter most, delivered as a PDF to your inbox.

Get my free audit
CallGet a quote