Why This Error Is Different From a Fatal PHP Error
Most WordPress errors — critical errors, white screens, 500s — come from PHP code failing to execute. A database connection error is different: it happens before WordPress can even load its own code, because the very first thing WordPress does on every page load is connect to MySQL to pull the site's content, settings, and configuration. If that connection fails, nothing else can happen, which is why this error appears instead of any normal page.
Step 1: Verify the Database Credentials in wp-config.php
Via FTP or your host's file manager, open wp-config.php in the site's root directory and locate these four lines near the top:
define( 'DB_NAME', '...' );
define( 'DB_USER', '...' );
define( 'DB_PASSWORD', '...' );
define( 'DB_HOST', '...' );
Compare each value against your hosting control panel's database section. This is the single most common cause of the error — a database password that was reset without updating wp-config.php, a site migrated to new hosting with old credentials still in place, or a simple typo. Correcting a mismatched value here resolves the majority of cases immediately.
Step 2: Confirm the Database Server Is Actually Running
If the credentials are correct, the next possibility is that the database server itself is down, overloaded, or unreachable — something to confirm with your host's status page or support, since this is a server-side issue outside of WordPress's files entirely. This is more common on shared hosting during high-traffic periods, where a database server serving many accounts at once can become temporarily unavailable.
Step 3: Check for a Corrupted Database Table
If credentials are correct and the database server is confirmed running, a corrupted table is the next likely cause. Most hosting control panels include phpMyAdmin, which has a built-in "Repair Table" option under the database's structure view. Alternatively, you can temporarily enable WordPress's own repair tool by adding this line to wp-config.php:
define( 'WP_ALLOW_REPAIR', true );
Then visit yoursite.com/wp-admin/maint/repair.php to run the repair. Remove this line from wp-config.php again once you're done — leaving it in place is a security risk, since the repair page has no login requirement while it's enabled.
Step 4: Rule Out a Connection Limit Issue
If the error appears only intermittently or only for some visitors, the hosting account may be hitting a maximum concurrent database connection limit during traffic spikes rather than facing an actual outage or misconfiguration. This is a capacity problem, not a configuration bug, and typically means the hosting plan or database resources need to scale to match the site's actual traffic.