Error Establishing a Database Connection
SSL, Security & Connection
Your site is fine. It just can't reach the place its content lives.
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
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
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
Too many connections
Traffic or a runaway process opened more connections than the limit allows. New requests are refused until some close.
- 4
A corrupted database table
Usually after an unclean shutdown or a disk problem. The connection works but a table cannot be read.
- 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.
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.
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.
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.
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.
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.
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.
If you’d rather not
We do this work every week. These are the services that cover it.
- Fixing Broken WebsitesSite down, hacked, or falling apart? We diagnose it fast, fix what's broken, and tell you straight how to keep it from happening again.
- WordPress Speed & OptimizationA slow site loses customers before they read a word. We tune WordPress for speed, stability, and search — measured, not guessed.
- Custom Web SolutionsBuild the web system your business actually needs. We design custom web systems around your offer, your team, your data, and the way buyers move from interest to action.
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.