A WordPress database connection error means your site cannot communicate with the database that stores its posts, pages, settings, and other essential information. Visitors may see an error instead of your site, and you may be unable to open the WordPress dashboard.
Common causes include incorrect connection details, a database service problem, or a change made during a migration. Work through the checks below in order. Start with low-risk steps, and change database settings only after verifying the correct values with your hosting provider.
What a WordPress database connection error means
WordPress relies on two main parts: its application files and its database. The files contain WordPress itself, along with themes and plugins. The database holds much of the site’s content and configuration. When WordPress cannot connect using the settings available to it, it cannot build the page.
The message may say “Error establishing a database connection,” but a blank page or a similar server error can have the same underlying cause. The message alone does not prove that your database is damaged or your content is lost. It means WordPress could not complete the connection at that moment.
WordPress database connection error: start with these checks
Before editing files or running repair tools, check whether the problem is temporary and whether anything changed recently.
- Open the site in a private browser window. This helps rule out a stale page or a local browser issue.
- Check both the public site and the dashboard. A failure in both places is more likely to affect the site broadly than a problem limited to one page or plugin screen.
- Look for a hosting status notice. Your hosting control panel or provider may report maintenance, a database outage, or an account resource issue.
- Think back to recent changes. A migration, hosting move, password update, configuration edit, or plugin installation can help narrow down when the failure began.
- Check whether other sites on the same hosting account are affected. Multiple failures at once may point to a shared service that your provider needs to investigate.
If your site serves customers, contact your host early rather than repeatedly changing settings. Support can often confirm whether the database server is running and whether your account can reach it.
Verify the database settings in wp-config.php
WordPress reads its database connection details from a file named wp-config.php, usually located in the main WordPress directory. The relevant settings include the database name, username, password, and host. A mismatch between any of these values and the details set up by your host can prevent a connection.
Use your hosting file manager or a secure file transfer method to inspect the file. Download a copy before making any edits so you can restore the original. Keep the file private: it contains sensitive credentials and should not be posted in a public support forum or sent through an unsecured channel.
Compare the values in the file with the database details in your hosting control panel or the information provided by your host. Check the spelling, capitalization, and any required account prefix. Some hosting setups use a database host other than localhost, so confirm the correct value for your account instead of assuming.
A password change in the hosting panel does not necessarily update WordPress automatically. Update the matching value only after confirming the new credential. If you are unsure which database belongs to the site, ask your host to identify it rather than testing random combinations.
Check whether the database service is available
Your settings may be correct while the database service is unavailable or temporarily overloaded. Your hosting provider can confirm whether the database server is operating and whether your site has permission to connect.
Ask support specific questions: Is the database server available? Can the account access the database named in the configuration file? Are there resource limits or account-level errors? Clear answers are more useful than resetting passwords without evidence.
When the host reports that the service is healthy, share the approximate time the issue started and mention any recent changes. If the error affects several sites or continues after the provider confirms recovery, ask support to check the server logs and account permissions.
Review recent migrations and configuration changes
After a site moves to a new host or is restored from a copy, the database may have a different name, username, password, or host value. A copied configuration file can still contain details from the old provider. Confirm that the active site’s wp-config.php matches the database created for the new hosting account.
Check whether the site moved into a different folder or whether the new host expects a different database host value. Avoid changing the database table prefix or other configuration constants as a guess. Those edits can create additional problems without fixing the connection.
If the error followed a configuration edit, compare the current file with the copy saved before the change. Restore the original if the edit introduced the error, then verify the correct settings with your host before trying again.
Use database repair only when there is evidence of damage
A damaged database is possible, but it should not be the first explanation you assume. Once the host confirms that the database is reachable, ask whether a repair is needed if WordPress still reports a database-related problem. Make a backup before attempting a repair, even when the site is unavailable.
Some WordPress installations support a temporary repair mode through a setting in wp-config.php. Use it only when your host or a qualified site administrator recommends it, and remove the setting immediately after the repair. Leaving a repair endpoint enabled can expose sensitive database tools to visitors.
For better recovery options, keep backups of both the WordPress files and the database. A safe backup plan helps you prepare before a failure occurs. Before restoring a backup, confirm that the files and database come from the same known-good point.
Safer habits while troubleshooting
- Leave database tables intact. They may contain your content, user accounts, and settings.
- Use only verified credentials. Repeated guesses can make the original problem harder to identify.
- Keep database passwords private. Treat them like account passwords, and replace them if they have been exposed.
- Save reinstalling WordPress for later. Reinstalling files usually will not fix a database outage or incorrect connection settings.
- Make one change at a time. This makes it easier to identify what resolved the issue.
When to contact your hosting provider
Contact your host when you cannot confirm the database name or host, the settings appear correct, the problem began after a server move, or the error continues after a temporary outage has passed. Send the site address, the time the problem began, the exact error message, and a short list of changes made just before it appeared.
Keep your database password out of ordinary support messages unless the provider offers a secure method and specifically needs it. In most cases, support can investigate the server and account settings without asking you to disclose the password.
Once the site is working, record which setting or service caused the failure and where the correct credentials are securely managed. That information can make a future migration or password update easier to handle. For a hosting incident, ask what monitoring or account changes could reduce the chance of a repeat.
