WordPress shows “Error establishing a database connection” when PHP cannot use the configured database connection reliably. The cause may be credentials, the database server itself, limits, corruption or environment changes.
Symptoms
- The standard “Error establishing a database connection” page appears.
- The error is intermittent during traffic spikes.
- wp-admin reports that one or more database tables are unavailable or need repair.
- The problem began after migration, password rotation or hosting changes.
Common causes
The same visible WordPress error can have several causes. A reliable fix starts by matching the symptom to logs, request behavior and recent changes.
- Incorrect DB_NAME, DB_USER, DB_PASSWORD or DB_HOST in wp-config.php.
- MySQL/MariaDB service outage or network connectivity issue.
- Database user permissions changed.
- Connection limits exhausted under load.
- Corrupted tables or disk/storage problems.
Safe diagnosis
- Confirm the database server is reachable independently of WordPress.
- Compare wp-config.php values with the hosting database credentials without exposing them publicly.
- Check server status, max connections and database error logs.
- Inspect table health only when connection is available.
Production safety: create a recovery point before changing code, plugins, database values or server configuration. Business-critical WooCommerce sites should avoid random deactivate/update experiments during active traffic.
How the issue is fixed
- Correct credentials or database host information.
- Restore the database service or resolve resource exhaustion.
- Repair affected tables after creating a verified backup.
- Update migrated URLs/configuration only if the connection itself is healthy.
Avoid this shortcut: Do not post database credentials in screenshots, tickets or public forums. Rotate them if they were exposed.
When to request expert WordPress bug fixing
Professional troubleshooting is useful when the site is business-critical, the error returns after a temporary fix, wp-admin is unavailable, the failure began after a complex update/migration, or you cannot identify the responsible code from logs. WP•FIX focuses on the smallest safe change that restores the failing path and explains the root cause.
FAQ
Does this mean my database was deleted?
Not necessarily. Most connection errors happen because WordPress cannot connect, even though the database still exists.
Can high traffic cause this error?
Yes. Connection limits or database overload can make the problem intermittent.
Why did it happen after migration?
The new host may use different database credentials, hostnames, ports or permissions.
Can a hacked site show this error?
It can, but this message alone is not evidence of malware. Configuration and server health should be checked first.
Need this WordPress issue fixed?
Send the URL, error message and what changed immediately before the problem started.
Request troubleshooting