A WordPress database connection error means the application cannot reach the database it needs to load your content. Start by checking the exact message, the timing of recent changes and the hosting provider’s database status. Avoid reinstalling WordPress or importing an old backup before you understand which connection has failed.
Record whether the error appears on the public website, the login screen or both. Note the first failure time and whether it is constant or intermittent. A cached homepage can still appear while uncached pages fail, so test more than one page. Share the error text and timestamps with your host, without including passwords or a copy of your configuration file.
The official WordPress error guide identifies the database name, username, password and host in wp-config.php as key connection settings to check. Compare them privately against the values supplied by your hosting provider. A migration or database-password change can leave the application using outdated details.
Keep a protected copy of the original configuration before an authorised administrator edits it. Use the host’s exact server name and connection instructions rather than assuming that every account uses localhost. Do not post credentials in support forums or place a downloadable configuration backup in the public website directory.
A reachable hosting dashboard does not by itself prove that the database service is healthy. Ask the provider to check the database service, account quota and relevant errors at the recorded time. If several sites on the same account fail together, include that observation. If only one site is affected, identify its database and recent changes to narrow the investigation.
Choose the repair that matches the evidence. Correct a confirmed configuration mismatch with a rollback copy ready. Escalate a service outage or quota problem to the host. If the provider reports damaged tables, agree on a backup and recovery plan before attempting a repair. A connection error alone is not evidence that tables should be deleted or the database replaced.
For a live store or enquiry website, establish what new records could be lost before restoring an older database. Record the backup time and the expected recovery point. Stop broad trial-and-error changes when the cause remains unclear; ask for help with the error details and the work already completed.
After the WordPress database connection error is resolved, test an uncached page, administrator access and the forms or transactions the business relies on. Check that recent content remains present. Review the original error window with the host and record the confirmed cause, the change made and how to reverse it.
If the symptom is a gateway timeout instead, see the Cloudflare 522 and 524 troubleshooting guide. For help diagnosing the database fault, use WordPress technical support and provide the timing, scope and non-sensitive error message.