You open your site and instead of your homepage there is a single line on a white page: Error establishing a database connection. No design, no menu, no login. For visitors, your website has effectively stopped existing.
The good news first: this message almost never means your content is gone. It means WordPress can no longer reach the place where your content lives. That is a very different problem — and usually a recoverable one.
What the Message Actually Says
WordPress keeps your site in two parts. The files on the server hold the code, the theme and your uploads. The database holds everything else: pages, posts, settings, users, orders. Every single page view requires WordPress to ask the database for content.
When that request fails, WordPress has nothing to display — so it shows this error instead. Both the public site and the admin area are affected, which is why you usually cannot log in to fix it from the dashboard.
The Most Common Causes
1. Wrong database credentials
WordPress stores the database name, user, password and host in wp-config.php. If any one of them stops matching — after a hosting migration, a password change at the host, or an accidental edit — the connection is refused. This is the single most frequent cause.
2. The database server is down or overloaded
On shared hosting, your database runs on a server used by many other customers. A traffic spike, a runaway script on a neighbouring site, or maintenance at the host can make it unreachable for minutes or hours. If the error comes and goes, this is a likely suspect.
3. Corrupted database tables
A crashed update, a full disk, or a plugin that wrote bad data can damage individual tables. Sometimes only the admin area shows a hint — a note that tables are unavailable or need repair — while the front end shows the generic error.
4. You have hit a hosting limit
Many plans cap the number of simultaneous database connections or the database size. A poorly written plugin, a bot crawling aggressively, or simply growth can push a site over that limit.
5. Corrupted core files or a compromised site
Less common, but important: damaged WordPress files or malware that has altered wp-config.php can produce the same error. In that case the message is a symptom of a bigger problem, and fixing only the connection leaves the real cause in place.
What to Check First
- Is it only you? Test from another device or network to rule out a cached error page.
- Does
/wp-adminshow a different message? A different wording there points towards damaged tables rather than credentials. - Did anything change recently? A migration, a new plugin, a password reset at the host, an update that ran last night.
- What does your host say? Check their status page — if the database server is down, nothing you change will help.
What Not to Do
This error tempts people into fast, risky moves. Avoid restoring an old backup before you know the cause — you may overwrite recent orders or content for nothing. Avoid editing wp-config.php by trial and error; one wrong character takes the site from "database error" to "completely broken". And do not run repair tools on a database you have not backed up first: a repair on already damaged tables can make the damage permanent.
Why It Keeps Coming Back
If you see this error more than once, it is rarely bad luck. Recurring database errors usually trace back to something maintenance would have caught: a database that has never been cleaned up, a plugin that opens too many connections, a hosting plan the site has outgrown, or no monitoring — so the first person to notice the outage is a customer.
Fixing it properly means finding out which of the causes above applies, confirming it in the server logs rather than guessing, and then removing the reason it happened — not just getting the page to load again.