Help for owners
My website just says Error establishing a database connection
Short answer
Error establishing a database connection means WordPress cannot reach the database that holds your pages, users and orders. WordPress's own guide says the usual cause is a wrong database name, username, password or host in wp-config.php. It also lists hosting problems, such as a database shut down for going over its quota or a server that is down, and hacked sites.
Does this sound like your situation?
- Every page of my WordPress site shows one white page with this error.
- The error appeared right after the site moved to a new host.
- It started after someone changed the hosting or database password.
- The site comes back for a while and then the error returns.
Why does this happen?
Wrong details in wp-config.php
WordPress's guide to common errors says this message is usually caused by an error in the wp-config.php file. The four values to check are the database name, the database username, its password and the database host. A site move or a password change at the host often leaves one of them out of date.
Confirmed by developer.wordpress.orgTechnical detail: WordPress says PHP is missing the MySQL extension
A problem at the web host
The same guide lists two hosting problems: the database has met its quota and been shut down, or the server is down. Neither one is fixed by changing WordPress files, which is why the host comes first.
Confirmed by developer.wordpress.org
A compromised site
WordPress says that if the settings and the host check out, the site may have been hacked, and suggests scanning it for compromise.
Confirmed by developer.wordpress.org
Too many visitors for the database
On small hosting plans, a burst of traffic or a stuck plugin can use up the database connections the plan allows, so the error comes and goes with load. Your host's logs show whether that is happening.
What can I do about it today?
- Check your host's status and noticesLook at the host's status page and the messages in your hosting account for an outage, a suspended database or a quota warning.
- Ask the host two direct questionsIs the database server for my site running, and is my database within its quota. Ask them to quote what the logs show.
- Write down what changed recentlyA move to a new host, a new password, a plugin or theme update, a new domain. Hand that list to whoever fixes it.
- Back up wp-config.php before any editIf someone is about to change wp-config.php, download a copy of the original first, so a typo can be undone in seconds.
- Hold off on restoring a backupRestoring an old backup over a database that is only unreachable can wipe recent orders, comments and sign-ups. Find the cause first.
When should I bring someone in?
- Your host reports no fault on its side and the wp-config.php values look correct.
- The site is a store and orders are being lost while it is down.
- You see unknown admin users, strange files or redirects alongside the error.
How do I handle it?
- Test the connection from the serverI connect to the database with the exact details in wp-config.php from the web server itself, which shows at once whether the details or the database are the problem.
- Read the host and database logsI check for quota limits, crashed tables or connection limits being hit, and fix or escalate with the host.
- Rule out a compromiseIf the setup is sound, I check for changed core files, unknown admins and injected code before the site goes back online.
- Prevent a repeatI set up uptime checks and database backups you can restore from, and record the working connection details somewhere safe.
The price depends on what I find, so I quote in writing after a short discovery call. Tell me what is happening and I reply within 24 hours.
What do owners ask about this?
What does error establishing a database connection mean?
It means WordPress tried to open its database and could not. The pages exist in the database, but the site cannot read them until the connection works.
Is my data gone?
Not usually. The error is about the connection. Confirm with your host that the database is still there before anyone restores or deletes anything.
How do I fix the database connection error after moving WordPress?
After a move, check the four values in wp-config.php against the new host's database details, since WordPress names those as the usual cause. Check the database host value as carefully as the password.
Was my site hacked?
It is possible. WordPress lists a compromised site as a cause once settings and hosting are ruled out, so check those two first.
Sources
For your developer: the technical fixes
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.WordPress says PHP is missing the MySQL extensionCan't connect to MySQL server on 'host' (111)MySQL accepts local logins but refuses connections from other machineswp-admin shows an empty white page and no errorwp-admin loads a completely blank page in WordPress
Related help
- My Heroku app says too many database connectionsAs an app adds dynos or background jobs it can run out.
- My website won't open and the browser says it redirected too many timesWith Cloudflare in front of the site, its documentation names the usual pairs: Flexible encryption with a server that forces HTTPS, Always Use HTTPS with a server that forces HTTP, or redirect rules that conflict.
- WordPress Site Redirects Visitors to SpamGoogle describes this as a hacked-content redirect that may depend on the visitor's referrer, device or browser, so you may never see it yourself.
- I used an AI tool to fix my app and now it is more broken than beforeFind out whether there is a saved earlier version: Git keeps the history of changes, and builders such as Bolt keep a version history you can restore.