HTTP 521 Web Server Is Down

Non-standard, from Cloudflare: the origin server refused the connection — it is down, or a firewall is blocking the CDN's addresses.

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

Where you meet HTTP 521 in production

When the origin web server process is stopped, the host is down, or a firewall or security group only allows a list of addresses that does not include the CDN's. A spike of 521s right after an infrastructure change usually points at the firewall.

Why you would test it

An origin outage seen through a CDN. Retry with backoff, show a maintenance message, and alert on it: unlike a single 500 it means nothing behind the CDN is answering.

What your client should do about a 521

The origin is not accepting connections, so every request will fail until it is back. Back off and retry slowly, show a maintenance or offline state rather than an error per action, and alert: this is an outage, not a bad request.

521 versus the codes it gets confused with

Endpoints that return 521

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

Questions about HTTP 521

How is 521 different from 503?
A 503 needs a running server to send it. A 521 is what the CDN reports when there is no server listening to send anything.
Can a client fix it?
No. It needs the origin or its firewall fixed.

Other server error codes

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

Last updated