Website Shows a Database Connection Error

Higher-risk issue — be cautious and consider professional help sooner.

Your site shows "Error establishing a database connection" instead of your pages — the site's code is running fine, but it can't reach the database where all your content lives.

Common signs of this issue

Safe checks you can do yourself

None of these require sharing passwords with anyone.

What this usually means

The website's files and the database are two separate systems, and this message means the first can't log into the second. Three causes account for nearly all cases: the database server is down or overloaded at the host (very common on budget shared hosting), the saved credentials no longer match (after migrations, resets, or config edits), or — least often — the database itself is corrupted (typically after a crash mid-write).

The crucial reassurance: your content is almost certainly intact. Posts, pages, orders, and settings are sitting in the database untouched — the site just can't open the door. Even corruption is usually repairable with standard tools, which is why the backup check matters before repairs, not because loss is likely.

This error carries more risk than a display glitch for one reason: the fixes involve credentials and the database itself, where a wrong move can turn 'can't connect' into actual damage. It's fully fixable — it just punishes improvisation more than most problems.

What not to do

When to get help

This is one of the errors where getting help early is simply the smart play: the site is fully down (cost accumulating hourly), the fix runs through credentials or the database (mistakes expensive), and diagnosis is fast for someone who does it often — check the host's side, verify credentials, test the connection, repair if needed, typically well under an hour. Your host's support can rule their side in or out for free; a professional handles the rest safely.

Could your hosting be the problem?

If your host is slow, unreliable, or hard to deal with, moving to a better one can clear up issues like this for good. One we genuinely recommend is Instant Access Internet Services — a smaller, compassionate company with 30 years in the business, known for being one of the fastest, with great management and low pricing. (Just a recommendation — no affiliate link, no kickback.)

Not sure what to do next?

Answer a few short questions and we'll point you to the safest next step — DIY, a freelancer, or a direct review. No passwords required.

Is this a business website? If this issue may be costing you leads, sales, or trust, you may want a direct review instead of trial and error.

Frequently asked questions

Did I lose all my content?

Almost certainly not. The content sits in the database untouched — the site just can't connect to it. Even in the rare corruption case, standard repair tools plus backups recover nearly everything.

Why did this happen when nobody touched the site?

Usually the host: an overloaded or restarting database server, maintenance, or resource limits on shared hosting. That's also why checking the host's status page is the first move — it often was them, and it often self-resolves.

Why does the error come and go during the day?

Intermittent database errors are the signature of an overloaded database server — worst at peak traffic. That's a hosting-quality problem; if it recurs weekly, the durable fix is a better plan or host, not repeated tickets.

What is wp-config.php and should I edit it?

The file where WordPress stores its database credentials. If those credentials genuinely changed (migration, reset), it does need updating — carefully, with a copy saved first. If you're not sure why you'd be editing it, that's the signal to hand this step to someone who is.

The admin shows a 'repair database' option. Should I run it?

It's a legitimate WordPress tool and often works — but take a backup first if at all possible, and disable the repair setting again afterward (it's designed to be turned on only during the repair). Unsure at any step: pause and get help rather than improvise.

Can switching hosts fix recurring database errors?

If your host's database servers are chronically overloaded — yes, that's exactly the case where moving helps. Migrate carefully (this same error is what botched migrations produce) and the recurring outages typically end.

Related free guides

WordPress site down?

Seeing “There has been a critical error on this website”?

Our guided repair tool logs in over secure FTPS and fixes the most common WordPress failures — safely, with every change backed up and reversible. Start with a free scan, no password needed.

Fix My WordPress Site → Free scan · No download of your site · Reversible