What 521 means
Unofficial, used by Cloudflare. Cloudflare tried to connect to the website’s own server (the origin) and the connection was refused.
When servers send it
When the web server isn’t running, or a firewall actively rejects Cloudflare’s connections.
Common causes
- The web server (nginx, Apache, the app) is stopped or crashed.
- A firewall or security tool blocking Cloudflare’s IP addresses.
- The origin listening on a different port than Cloudflare uses.
How to fix it as a developer
- Check the web server is running and listening on ports 80 and 443.
- Allow all of Cloudflare’s published IP ranges in the origin’s firewall.
- Check security plugins or fail2ban haven’t banned Cloudflare addresses.
How to fix it as a visitor
- Try again later. The website’s server is down.
Related codes
- 520 Web Server Returned an Unknown Error: Cloudflare reached the website’s server but got back an empty, unknown or unexpected response.
- 522 Connection Timed Out: Cloudflare couldn’t connect to the website’s server in time.
- 523 Origin Is Unreachable: Cloudflare can’t find a route to the website’s server at all.
- 502 Bad Gateway: A proxy or load balancer got an invalid response, or none at all, from the server behind it.
Where it’s defined
521 isn’t in any RFC or the IANA status code registry. It’s used by Cloudflare. Reference: Cloudflare docs: error 521.
Other 5xx codes
500 Internal Server Error · 501 Not Implemented · 502 Bad Gateway · 503 Service Unavailable · 504 Gateway Timeout · 505 HTTP Version Not Supported · 511 Network Authentication Required · 520 Web Server Returned an Unknown Error · 522 Connection Timed Out · 523 Origin Is Unreachable · 524 A Timeout Occurred · 525 SSL Handshake Failed · 526 Invalid SSL Certificate
Or search them all in the HTTP status code list.