WordPress could not connect to its database, so it cannot build any page. Either the details in wp-config.php are wrong — the name, user, password or host — or the database server is down or refusing connections. After a move or a password change it is almost always the details.
Error establishing a database connection
How 3 other clients word the same error
In the admin, or with debugging on
This either means that the username and password information in your wp-config.php file is incorrect or that contact with the database server at localhost could not be established. This could mean your host’s database server is down.
The database exists but cannot be used
Cannot select database
Tables missing or damaged
One or more database tables are unavailable. The database may need to be repaired.
| Error | Error establishing a database connection |
| Usually fixed by | The site owner or host |
| Status | 500 |
| Details in | wp-config.php: DB_NAME, DB_USER, DB_PASSWORD, DB_HOST |
| On cPanel | Names are prefixed with the account user: user_wpdb |
Check the site from outside
Enter the address: we load it from our network and show the status code, how long it took, and the error if it failed.
What it means
Every WordPress page is built from the database, so without a connection nothing loads. Visitors see the one line; signed-in admins, and anyone when debugging is on, see the longer version with the database host it tried.
Why it happens
- A wrong database name, user, password or host in wp-config.php — common after moving the site or changing the database password.
- On cPanel, a name without the account prefix: WordPress’s own hint is that the database may be called username_wpdb.
- The database user no longer has rights on the database.
- The database server is down, overloaded or out of connections.
- Damaged tables — WordPress then says the database may need to be repaired.
How to fix it
- Compare DB_NAME, DB_USER, DB_PASSWORD and DB_HOST in wp-config.php with the database in the host’s panel (cPanel → MySQL Databases), and make sure the user is added to the database with all privileges.
- If the details are right, ask the host whether the database server is up.
- For damaged tables, add define( ‘WP_ALLOW_REPAIR’, true ); to wp-config.php, open /wp-admin/maint/repair.php, then remove the line.
If you are visiting the site
- Nothing on your side causes it; the site owner or host has to fix it.
See it for yourself
grep -E "DB_(NAME|USER|HOST)" wp-config.php
mysql -h localhost -u user_wp -p user_wpdb -e 'SELECT 1'
Try the same details by hand: “Access denied” means the user or password; “Unknown database” the name; “Can’t connect” the host or the server.
Sources
Error text and meaning checked on 25 September 2026 against these official sources:
- wordpress-develop/src/wp-includes/class-wpdb.php at trunk — github.com
- wordpress-develop/src/wp-includes/functions.php at trunk — github.com
- Editing wp-config.php — developer.wordpress.org