Fixing WordPress Database Connection Errors

Separate application configuration from database availability and storage failures.

2 min read

  • Article
  • Intermediate
  • 2 minutes read
  • Reviewed August 4, 2026
  • WordPress maintenance and troubleshooting

“Error establishing a database connection” means WordPress could not use the configured database successfully.

The cause can be incorrect credentials, an unavailable database server, exhausted resources, network failure or damaged tables.

Check Scope

Determine whether:

  • The public site and wp-admin both fail.
  • Other applications using the database fail.
  • The error is intermittent.
  • A migration or credential change just occurred.
  • Hosting reports a service incident.
  • Disk or connection limits are exhausted.

Verify wp-config.php

Check:

  • Database name.
  • username.
  • password.
  • host.
  • port or socket.
  • table prefix where relevant.

Do not publish these values in support screenshots or logs.

Test the Database Service

Use hosting tools, a database client or WP-CLI to confirm that the configured account can connect and access the intended database.

If the service itself is down, application changes will not repair it.

Capacity and Intermittent Failures

Connection limits, storage exhaustion, CPU saturation and database restarts can cause temporary failures.

Review server metrics and logs around the exact timestamps.

Corrupted Tables

If WordPress connects but reports table problems, create a backup and use an appropriate repair process.

WP_ALLOW_REPAIR exposes a repair interface without normal login and must be removed immediately after use.

Frequently Asked Questions

Should the database password be reset first?

Not without evidence. A reset can create another outage if the configuration and other services are not updated together.

Can a cache keep the site visible during database failure?

Full-page caches may continue serving selected public pages, but dynamic and administrative functions still fail.

Continue Learning

Previous: Troubleshooting Fatal Errors and Blank Pages

Next: WordPress Memory Limits and Timeouts