WebCare.

WordPress problem fix

ERROR ESTABLISHING A DATABASE CONNECTION

This usually means wrong credentials, a crashed database server, or a corrupted database. All three are recoverable, usually with zero data loss.

4 hour emergency response You only pay when it is fixed 150+ WordPress sites managed

The short answer

When WordPress shows 'error establishing a database connection', the site is up but cannot talk to its database. The cause is one of four things: wrong database credentials in wp-config.php, the database server is down or restarting, the database is corrupted, or the host has hit a connection limit. Your content is almost always still there. The fix is to confirm credentials, repair the database, and restart the service. Usually under an hour.

Is this your situation?

If any of these match, you are on the right page.

Every page shows the database connection error

It started right after a host migration or update

wp-admin is also unreachable

The error appears at busy traffic times then clears

What usually causes it

Are the database credentials in wp-config.php correct?

If a host changed the password or you migrated, DB_USER, DB_PASSWORD, DB_HOST, or DB_NAME may be stale. This is the first check.

Is the database server actually running?

Shared hosts sometimes restart MySQL or MariaDB. If the service is down, no credentials will work until it is back.

Is the database corrupted?

A crash or bad import can corrupt a table. WordPress can self-repair with WP_ALLOW_REPAIR in wp-config.php.

Has the host hit a connection limit?

Cheap shared hosts limit concurrent database connections. A traffic spike or a slow plugin query exhausts the pool and triggers the error.

How we fix it

The real method, in the order it works.

  1. 1

    Open wp-config.php and confirm DB_HOST, DB_USER, DB_PASSWORD, and DB_NAME match what the host shows.

  2. 2

    Try to log into phpMyAdmin or the host control panel with the same credentials to confirm.

  3. 3

    Add define('WP_ALLOW_REPAIR', true) to wp-config.php and visit /wp-admin/maint/repair.php to repair tables.

  4. 4

    Restart the database service or ask the host to restart it.

  5. 5

    If a connection limit is the cause, fix the slow query or upgrade the host.

Real fix, from our work

How this one actually went down

A SaaS founder messaged us during a launch saying the marketing site was throwing database errors. Credentials were correct. Host showed MySQL using 100 percent of allowed connections. We found a poll plugin firing an unindexed query on every page view. Added the index, throttled the plugin, restarted MySQL. Site stayed up through the launch.

AJ

Written by Ali Yasin Jatoi

Founder of WebCare Studios. Ali has worked with WordPress for more than 10 years, including managing a fleet of 150+ sites with WP-CLI automation for updates, security cleanup, and malware removal. He has hands on experience across major hosts including Cloudways, A2 Hosting, Hostinger, and Bluehost.

Why owners pick WebCare

4 hour emergency response

Site down, hacked, or broken checkout gets a senior engineer within 4 hours. No ticket queues, no bots.

You only pay when it is fixed

Flat quote up front. If we cannot get you back online, you do not pay. Risk sits with us, not you.

Data safe approach

We work on a snapshot first and never touch your live database until the fix is verified safe.

150+ sites managed

We run a fleet of WordPress sites every day. The errors you are seeing are ones we have closed hundreds of times.

Common questions

Will I lose my WordPress data with a database connection error?+

Almost never. The error means WordPress cannot reach the database, not that the database is destroyed. Once the connection is restored, all content returns.

Why does the database error come and go?+

Intermittent errors usually mean connection pool exhaustion or a flaky database server. The fix is to find what is opening too many connections, often a runaway plugin query or a backup job.

Can I fix this myself?+

Sometimes. Wrong credentials are simple. Corruption and connection limits usually need someone who can read the slow query log and edit server config.

How long to fix a database connection error?+

Wrong credentials take five minutes. Repair or restart takes thirty. Slow query or host capacity issues take a couple of hours to fix permanently.

Send my site for triage in 15 minutes

Two fields. Email and your URL. A senior WordPress engineer reads it within minutes and replies on email and WhatsApp with what is wrong and what we will do next.

Two fields. Senior engineer replies within 15 minutes during business hours.

Related fixes

WhatsApp Get my site fixed