WordPress "Error establishing a database connection"
WordPress says "Error establishing a database connection". Why your site cannot reach its database, the common causes, and what to check before panicking.
You might be seeing
Error establishing a database connectionThe whole site, including /wp-admin, shows the same message
What it means
Every WordPress page is built from content stored in a database. This message means WordPress tried to open that database and could not. Your posts and pages are normally still safe inside the database. The connection to it is what failed.
What usually causes it
- The database server is down or overloaded. On shared hosting this is common during traffic spikes, and often temporary.
- Login details changed. The database name, username, password or host in
wp-config.phpno longer match. This happens after a migration, a host change, or a password reset in the hosting panel. - The database is damaged, for example after a crash during an update.
- Your hosting account hit a limit, such as disk space or the number of connections allowed.
What you can check yourself
- Wait five minutes and reload. If the host’s database server was briefly overloaded, the site may come back on its own.
- Check your host’s status page or dashboard for outage or maintenance notices.
- Check your disk usage in the hosting panel. A full disk can stop the database from working.
- Remember recent changes. Did you move the site, change hosting plans, or change a database password?
Avoid running “repair” tools you are unsure about, and do not edit wp-config.php without a copy of the original. A wrong change there keeps the site down.
When to ask for help
- The site is still down after 15 minutes and your host reports no outage.
- You recently moved or restored the site.
- The error appears only on some pages, or only in
/wp-admin.
Tell me your hosting company and what changed recently. I can check the connection details and the database itself, with temporary access that you can remove afterwards.
Updated