Error establishing a database connection on WordPress

On shared hosting the database user's connection quota is enforced per account, so a traffic spike or a second site on the same credentials exhausts it while the database server itself stays healthy.

Why it happens on WordPress

On shared hosting the database user's connection quota is enforced per account, so a traffic spike or a second site on the same credentials exhausts it while the database server itself stays healthy.

The fix on WordPress

Enable a persistent object cache (Redis or Memcached) to collapse repeated queries, give each site its own database user, and set WP_MEMORY_LIMIT explicitly. Check the host's control panel for a connections-per-user cap before raising anything server-side.

If that didn't fix it

WordPress has its own failure mode, but Error establishing a database connection has a wider set of causes. The most common one overall is: The database server is down or out of memory.

Check the database service status and its error log. An out-of-memory kill on a small VPS is the classic cause of an intermittent version of this error.

Check your own domain

An external probe records whether the failure is constant or intermittent, and captures the exact minutes it occurs — which is what distinguishes wrong credentials from connection exhaustion.

Frequently asked questions

Why does Error establishing a database connection happen on WordPress?

On shared hosting the database user's connection quota is enforced per account, so a traffic spike or a second site on the same credentials exhausts it while the database server itself stays healthy.

How do I fix Error establishing a database connection on WordPress?

Enable a persistent object cache (Redis or Memcached) to collapse repeated queries, give each site its own database user, and set WP_MEMORY_LIMIT explicitly. Check the host's control panel for a connections-per-user cap before raising anything server-side.

What does Error establishing a database connection mean?

WordPress loaded but could not connect to MySQL. Either the credentials in wp-config.php are wrong, the database server is down, or connections are exhausted under load.