---
title: "Error establishing a database connection on WordPress:…"
description: "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…"
canonical: "https://lemwatch.com/errors/error-establishing-a-database-connection/in-wordpress"
source: "https://lemwatch.com"
---

# 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.


## Related

- [All causes of Error establishing a database connection](https://lemwatch.com/errors/error-establishing-a-database-connection)
- [All website error codes](https://lemwatch.com/errors)
- [Error establishing a database connection on Cloudflare](https://lemwatch.com/errors/error-establishing-a-database-connection/in-cloudflare)
- [Free Uptime & response check](https://lemwatch.com/tools/website-uptime)
- [Server DNS address could not be found: Chrome's plain-English DNS failure message](https://lemwatch.com/errors/server-dns-address-could-not-be-found)
- [Lemwatch pricing](https://lemwatch.com/pricing)
