---
title: "Error establishing a database connection on Cloudflare:…"
description: "Cloudflare caches the error page itself, so visitors keep seeing the database error for minutes after the database is back."
canonical: "https://lemwatch.com/errors/error-establishing-a-database-connection/in-cloudflare"
source: "https://lemwatch.com"
---

# Error establishing a database connection on Cloudflare

> Cloudflare caches the error page itself, so visitors keep seeing the database error for minutes after the database is back.

## Why it happens on Cloudflare

 Cloudflare caches the error page itself, so visitors keep seeing the database error for minutes after the database is back.

## The fix on Cloudflare

 Purge everything in Cloudflare → Caching after the fix, and set a Cache Rule that bypasses cache for 5xx responses so a future outage does not stick.

## If that didn't fix it

 Cloudflare 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 Cloudflare?

 Cloudflare caches the error page itself, so visitors keep seeing the database error for minutes after the database is back.

### How do I fix Error establishing a database connection on Cloudflare?

 Purge everything in Cloudflare → Caching after the fix, and set a Cache Rule that bypasses cache for 5xx responses so a future outage does not stick.

### 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 WordPress](https://lemwatch.com/errors/error-establishing-a-database-connection/in-wordpress)
- [Free Uptime & response check](https://lemwatch.com/tools/website-uptime)
- [Website monitoring overview](https://lemwatch.com/website-monitoring)
