Web Hosting

Fix WordPress "Error Establishing a Database Connection"

Error establishing a database connectionwp-configdatabase is down
6 min read Updated 12 June 2026 ESAGAMES Team

This 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
One site or all sites?

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 hosting that just works

Our web hosting runs WordPress on fast NVMe with managed databases and DDoS protection included.

See web hosting
FAQ

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.

Knowledge base

Related articles

Skip the troubleshooting

Managed, protected hosting in Frankfurt — we handle the Linux, the network and the DDoS so you don't have to.

Payments Secure checkout with cards, banking apps and digital wallets.

Choose the payment flow that fits your stack and region without leaving the platform.

Pay by Zen Visa Mastercard Paysafecard PaysafeCash Skrill Trustly Bancontact UnionPay iDeal WebMoney