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

  1. 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.
  2. 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

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.