Troubleshooting · Practical guide

Error establishing a database connection in WordPress

WordPress cannot reach its database when credentials, server availability or database permissions are wrong.

Quick answer

WordPress cannot reach its database when credentials, server availability or database permissions are wrong.

Start with the checks below. Each step explains what to look for and what to try next.

What the error means

WordPress is unable to connect to the database configured in its wp-config.php file. This can happen after a migration, password change, outage or resource exhaustion.

Check without exposing credentials

Check without exposing credentials

Database service down

Check whether the database service is reachable through your hosting tools.

Configuration mismatch

Carefully compare database name, host and account values with the installed site.

After a migration

Confirm the database was imported and the application references the new environment.

Only intermittent errors

Check connection limits, resource pressure and relevant logs.

Before you continue: Never paste database passwords or the full wp-config.php into a public ticket.

Check safely

  1. Confirm the database service is available in your hosting dashboard or status tools.
  2. Compare DB_NAME, DB_USER and DB_HOST with the expected values without revealing secrets in a ticket.
  3. Check that the database user has the required permissions.
  4. Review recent migrations, password changes and server errors.

Avoid exposing credentials

Do not post wp-config.php contents, database passwords or connection strings in public forums or screenshots.

When to escalate

If the database service is down or the connection errors persist despite correct settings, contact hosting support with a timestamp, affected hostname and sanitized errors.

How to confirm the issue is resolved

  1. Repeat the original action that produced the issue.
  2. Check the result in a second browser or network when relevant.
  3. Review logs or status messages for remaining errors.
  4. Keep a short record of what changed so it can be reversed if necessary.

If the issue persists, contact support with the exact error, time, affected domain and actions already tried—never include passwords or secret keys.

What each database check tells you

A database connection error generally means WordPress cannot complete its connection to MySQL/MariaDB. Work from the least disruptive check to the most involved one:

  1. Only this site fails: Check the database name, username, password and host in wp-config.php against your hosting control panel. Do not paste credentials into a support ticket.
  2. Several sites on the account fail: Check for a broader database service incident or resource issue before editing every site's files.
  3. The error started after a migration: Verify that the database was imported and that the new user has privileges for the new database.

Do not replace the database or restore an old backup merely to test connectivity. Take a fresh backup first if the site is accessible. If you need help, share the error wording and when it began—not database passwords. For other server-side problems, see the 500-error guide.

Guidance may vary by plan, control panel version and enabled features. Review the settings available to your account before changing live services.