520 Web Server Returned an Unknown Error

Cloudflare reached the origin server and got back something it could not interpret as a valid HTTP response.

Last updated . How this page is checked.

Status code520
Status textWeb Server Returned an Unknown Error
Category5xx Server Error
Response has bodyUsually
Defined byCloudflare (not an IANA-registered code)

What does 520 Web Server Returned an Unknown Error mean?

Cloudflare reached the origin server and got back something it could not interpret as a valid HTTP response. It is numbered in the 5xx Server Error range but is not a registered HTTP status code, so the general meaning of that class is only a rough guide to it.

When do APIs return 520?

On sites behind Cloudflare. It is the catch-all for an origin that answered wrongly: it reset the connection, sent an empty reply, sent headers larger than Cloudflare accepts, or returned a malformed response. A crashing application process is the most frequent cause.

How to fix a 520 Web Server Returned an Unknown Error

The fault is at the origin, so that is where to look. Check the origin's error log at the time of the failure for a crash or restart. Request the same URL directly from the origin, bypassing Cloudflare, and see what actually comes back. Look for oversized response headers, usually cookies, and make sure nothing at the origin is dropping connections from Cloudflare's addresses.

Reproduce a 520 response

The fastest way to understand a status code is to trigger one and read the full response. Open the API tester and send a request to https://httpbin.org/status/520 — you will see the 520 status along with every response header the server sent. Comparing those headers against a working request is often what reveals the cause.

That response only imitates the number, which is useful for checking how your own client, alerting or retry logic treats a 520. A real one comes from the software named in the table above, in the circumstances this page describes.

When you are debugging a real endpoint, check the response headers as carefully as the body, and confirm you are using the right HTTP method for the operation.

Related 5xx status codes

See also

  • 502 Bad Gateway — A server acting as a gateway or proxy received an invalid response from the upstream server.
  • 521 Web Server Is Down — Cloudflare tried to connect to the origin server and the connection was refused.
  • 522 Connection Timed Out — Cloudflare tried to open a TCP connection to the origin server and got no answer in time.

References