Cloudflare Error 520: Web server returned an unknown error

Cloudflare reached your origin and got back a response it could not interpret — an empty reply, a malformed header, or a connection dropped mid-response. The origin is up but misbehaving.

Short answer

Cloudflare reached your origin and got back a response it could not interpret — an empty reply, a malformed header, or a connection dropped mid-response. The origin is up but misbehaving.

What Cloudflare Error 520 means

520 is Cloudflare's catch-all for 'the origin answered, but not with valid HTTP'. It is a symptom of the origin crashing, sending oversized headers, or resetting connections rather than a Cloudflare fault.

Causes and fixes, most likely first

  1. The origin crashes or resets the connection mid-response. Check origin error logs at the exact timestamp. Memory-limit kills and PHP fatals produce this reliably.
  2. Response headers are too large for Cloudflare's limits. Trim large cookies and verbose headers. Cloudflare enforces stricter header limits than most origins.
  3. The origin returns an empty response with no status line. Reproduce by requesting the origin IP directly with the Host header set — bypassing Cloudflare shows the raw behaviour.

How to stop it happening again

Check your own domain

Probing the hostname externally and comparing against a direct origin request separates a Cloudflare-layer issue from an origin fault.

Frequently asked questions

Is error 520 Cloudflare's fault?

Almost never. It means Cloudflare could not make sense of what the origin returned. The evidence is in the origin's logs.