HTTP 520 Web Server Returned an Unknown Error

Non-standard, from Cloudflare: the origin answered with something Cloudflare could not interpret — an empty, malformed or unexpected response, or a reset connection.

Non-standard — not defined by any RFC. Vendor documentation: Cloudflare 5xx error reference

Where you meet HTTP 520 in production

Behind Cloudflare, when the origin crashes mid-response, sends headers too large or malformed to parse, returns an empty reply, or resets the connection. It often appears during deploys, when a process restarts while requests are still in flight.

Why you would test it

Test that your client treats it as a retryable upstream failure, and that your logs keep the CDN request id so the origin team can find the matching request.

What your client should do about a 520

Treat it like a 502: an upstream failure that may succeed on retry. Retry idempotent requests with backoff and a cap, keep the CDN request identifier (CF-Ray) in your logs, and do not retry non-idempotent requests without an idempotency key.

520 versus the codes it gets confused with

Endpoints that return 520

1 endpoint in this playground answers with 520. Every one is free, needs no signup, and can be called from the browser or with curl.

Questions about HTTP 520

Is a 520 my fault or the CDN's?
Almost always the origin's: the CDN received something it could not use. Check the origin's logs at the time of the request.
Should I retry?
For safe and idempotent requests, yes, with backoff. Many 520s are transient — a worker restarting.

Other server error codes

All HTTP status codes · All 55 mock REST APIs · Getting started guide

Last updated