Error Establishing a Database Connection

SSL, Security & Connection

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

Fix it now: $249Fixed price. We start within one business day. Full refund if we can't fix it.
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 1 — Check 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 2 — Verify 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 3 — Test 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 4 — Repair 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 5 — Restart 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.

Fix it now, fixed price

Site down or white screen

500 and 502 errors, a white screen, a database connection error, a site that broke after a PHP update.

  • Back online first, then the cause
  • A full backup once it is up
  • A note on what failed and how to keep it from happening again
$249one time
  • We start within one business day of payment.
  • Full refund if we can't fix it.

Secure checkout by Stripe. After you pay, we show you how to give us access without sharing a password.

Not sure this is your problem? Ask us first.

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