Fix WordPress "Error Establishing a Database Connection"
Error establishing a database connectionwp-configdatabase is downThis WordPress error means it couldn't reach its database. The cause is almost always the credentials in wp-config.php, the database being down, or corrupted tables. Here's how to fix each.
Cause 1: wrong credentials in wp-config.php
After a migration or password change, the details in wp-config.php stop matching the database. Confirm all four:
define('DB_NAME', 'your_db');
define('DB_USER', 'your_user');
define('DB_PASSWORD', 'your_password');
define('DB_HOST', 'localhost'); // sometimes 127.0.0.1
If the login itself is denied, see MySQL access denied (1045).
Cause 2: the database server is down
If MySQL/MariaDB isn't running, every site on it shows this error. Restart it and check why it stopped — see MySQL/MariaDB won't start:
systemctl status mariadb && systemctl restart mariadb
Cause 3: corrupted database tables
A crash can corrupt tables. WordPress has a built-in repair tool — enable it temporarily in wp-config.php, run it, then remove the line:
define('WP_ALLOW_REPAIR', true);
// then visit /wp-admin/maint/repair.php
If every site on the server is down, the database server itself is the problem. If just one WordPress site is, it's that site's credentials or tables.
Check wp-config credentials first, confirm the DB server is running, then repair tables if needed. One site = config; all sites = the DB server.
WordPress is a trademark of the WordPress Foundation. ESAGAMES is an independent hosting provider, not affiliated with or endorsed by the WordPress Foundation.
WordPress hosting that just works
Our web hosting runs WordPress on fast NVMe with managed databases and DDoS protection included.
Frequently asked questions
What causes "Error establishing a database connection" in WordPress?
WordPress can't reach its database — usually wrong credentials in wp-config.php, the MySQL/MariaDB server being down, or corrupted tables. Check the credentials and that the database is running.
How do I know if it's the database server or just my site?
If every site on the server shows the error, the database server is down — restart it. If only one WordPress site does, it's that site's wp-config credentials or corrupted tables.
How do I repair a corrupted WordPress database?
Add define('WP_ALLOW_REPAIR', true); to wp-config.php, visit /wp-admin/maint/repair.php, run the repair, then remove the line. Back up the database first.
Related articles
Fix "500 Internal Server Error" on Your Website
A 500 error on your site? The usual causes — .htaccess, file permissions, PHP — and how to fix them.
Read fix Web HostingHow to Point a Domain to Your Server (DNS A Record)
How to point a domain at your server with an A record — and why it doesn't work instantly.
Read fix Web HostingFix Email Going to Spam (SPF, DKIM & DMARC Explained)
Mail landing in spam? Set SPF, DKIM and DMARC correctly so your email reaches the inbox.
Read fix