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
- The whole site — every page — shows "Error establishing a database connection" on a plain white background.
- The admin area is down too, sometimes with a slightly different message offering a "repair" option.
- It appeared suddenly with no edits on your end, or it comes and goes at busy times of day.
- It followed a migration, a hosting change, a password reset, or an edit to the site's configuration file.
- Your host may have emailed about database maintenance or resource limits around the same time.
Safe checks you can do yourself
None of these require sharing passwords with anyone.
- Confirm it's site-wide (homepage, an inner page, /wp-admin). A database error takes down everything at once — if only some pages fail, you're in different territory (see the white-screen guide).
- Check your host's status page and your hosting dashboard for database-server outage or maintenance notices — on shared hosting, an overloaded or restarting database server is the most common cause and fixes itself with zero action from you.
- Note the pattern: intermittent (works, fails, works — usually an overloaded database server, a hosting-quality problem) versus constant since a known event (a migration or config edit — the saved credentials probably no longer match).
- Recall the last 48 hours: a site migration, a hosting plan change, anyone resetting a database password in cPanel, or edits to
wp-config.php. Database credentials changing while the config file still holds the old ones is the classic self-inflicted version. - Confirm a recent backup exists — hosting-side or plugin — before anyone starts fixing. For this error specifically, verify the backup includes the database, not just files.
- Open a ticket with your host in parallel: ask "is the database server for my account up, and has my database hit any resource or corruption limits?" They can see in seconds what you can't see at all.
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
- Don't guess at database credentials in the config file — repeated wrong guesses can trigger host security blocks on top of the original problem.
- Don't run database repair operations without a backup taken first — repair tools usually help, but 'usually' is why the backup comes first.
- Don't reinstall WordPress — the software isn't broken, the connection is, and reinstalls risk the one thing that matters (the database).
- Don't delete anything: not the database, not tables that 'look wrong,' not config files. Nothing about this error is fixed by deletion.
- Don't repeatedly refresh a struggling site — if the database server is overloaded, hammering it extends the outage.
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.