Reference

Cloudflare 5xx Error Codes, Explained

Cloudflare's 5xx codes all describe a failure between Cloudflare's edge and your origin server, but each one points at a different layer. Knowing which code you have cuts troubleshooting time in half. Here's the whole family, what each means, and where to start.

520
Web server returning an unknown error

The origin replied, but with something empty or malformed Cloudflare couldn't parse.

521
Web server is down

The origin actively refused the connection. Usually a firewall or a dead web server process.

522
Connection timed out

Cloudflare couldn't complete the TCP handshake with the origin at all.

524
A timeout occurred

The connection succeeded but the origin took too long to send an HTTP response.

525
SSL handshake failed

The TLS handshake between Cloudflare and the origin couldn't complete.

526
Invalid SSL certificate

Cloudflare reached the origin over HTTPS but rejected its certificate as invalid.

How to read the family

These codes form a rough sequence that follows the connection from start to finish. A 522 or 521 means Cloudflare couldn't even connect: a 521 is an active refusal, a 522 is silence. A 525 or 526 means the connection started but the TLS layer failed: a 525 is a broken handshake, a 526 is a rejected certificate. A 524 means the connection and request went fine but your server answered too slowly. And a 520 is the catch-all: the server answered, but with something Cloudflare couldn't parse.

One thing holds across all of them: these are origin-side failures. Cloudflare generates the error page, but the cause almost always lives on your server or in the link between your server and Cloudflare. The visitor's browser and connection are rarely the issue, which is why "try a different browser" almost never helps with a 5xx.

The fastest way to narrow it down

Whatever the code, the most useful first move is to take Cloudflare out of the path and hit your origin directly. Pull your origin IP from the Cloudflare DNS settings and run a curl or openssl probe straight at it. If you reproduce the failure without Cloudflare involved, the problem is purely your server. If the origin responds cleanly when hit directly but Cloudflare still errors, the problem is in the Cloudflare-to-origin link: firewall rules, IP allowlisting, or TLS configuration specific to how Cloudflare connects.

Every code on this page is a server that just failed

The common thread across all six is an origin that stopped serving correctly. failover.io watches for exactly these failures from outside your network and escalates from email to SMS to a phone call until someone acknowledges, so you find out before your visitors do. Free plan: 5 monitors, no card.

Start monitoring free