DB Connection critical
Error Establishing a Database Connection
WordPress can’t reach its database — the whole site goes down with this single line. Here’s how to restore it.
What you see
Error establishing a database connection
What’s actually happening
WordPress stores everything in MySQL/MariaDB. If it can’t connect, nothing renders — just this one sentence. Either the credentials are wrong, the database server is down, or the database is corrupted.
Common causes
- Wrong database credentials in wp-config.php (after a migration or host change)
- The database server is down or overloaded
- A corrupted database table
- The host hit a connection limit (common on shared hosting under load)
How to fix it
- Verify the credentials in wp-config.phpConfirm DB_NAME, DB_USER, DB_PASSWORD and DB_HOST exactly match what your host shows. A migration to a new host is the #1 cause of a mismatch.
- Check whether the database server is upIn your host’s panel (or phpMyAdmin), confirm the database is online and you can log in. If the DB server is down or maxed on connections, contact the host.
- Repair the databaseAdd define(‘WP_ALLOW_REPAIR’, true); to wp-config.php, then visit /wp-admin/maint/repair.php to repair corrupted tables. Remove the line afterward.
- Confirm DB_HOST is correctIt’s often ‘localhost’, but some hosts use a specific hostname or socket. The wrong host value silently fails to connect.
Related errors