---
title: "ERR_CONNECTION_CLOSED: causes and how to fix it"
description: "The server closed the connection cleanly but before sending a complete response. Close cousin of a reset, and the same short list of causes: crashing…"
canonical: "https://lemwatch.com/errors/err-connection-closed"
source: "https://lemwatch.com"
---

# ERR_CONNECTION_CLOSED: The server closed the connection unexpectedly

> The server closed the connection cleanly but before sending a complete response. Close cousin of a reset, and the same short list of causes: crashing workers, aggressive keep-alive settings, or a proxy giving up.

## Short answer

 The server closed the connection cleanly but before sending a complete response. Close cousin of a reset, and the same short list of causes: crashing workers, aggressive keep-alive settings, or a proxy giving up.

## What ERR_CONNECTION_CLOSED means

 Where a reset is abrupt, a close is orderly — but still premature. The browser had a valid connection and the far end hung up before the response was complete.

## Causes and fixes, most likely first

- A keep-alive timeout on the server is shorter than the proxy's, so the proxy reuses a connection the server has already closed. Make the origin's keep-alive timeout longer than the proxy's, never shorter.
- The worker process was recycled mid-request. Check worker recycling settings (max requests, memory limits) and enable graceful shutdown so in-flight requests finish.

## How to stop it happening again

- Document and align keep-alive timeouts across every hop: CDN, load balancer, origin.

## Check your own domain

 Repeated external probes reveal whether the closure is systematic or tied to connection reuse, which is the key distinction here.

## Frequently asked questions

### Why does the error only happen on repeat visits?

 Because the first visit opens a fresh connection and later ones reuse a pooled connection the server has since closed. That is the keep-alive mismatch signature.


## Related

- [All website error codes](https://lemwatch.com/errors)
- [ERR_CONNECTION_RESET](https://lemwatch.com/errors/err-connection-reset)
- [ERR_EMPTY_RESPONSE](https://lemwatch.com/errors/err-empty-response)
- [ERR_CONNECTION_TIMED_OUT](https://lemwatch.com/errors/err-connection-timed-out)
- [HTTP 502](https://lemwatch.com/http-status-codes/502)
- [Free Uptime & response check](https://lemwatch.com/tools/website-uptime)
- [ERR_CONNECTION_REFUSED: The server actively refused the connection](https://lemwatch.com/errors/err-connection-refused)
- [ERR_CERT_REVOKED: The certificate was revoked by its issuer](https://lemwatch.com/errors/err-cert-revoked)
