Cloudflare 520-526 errors: what each means and how to fix it
Cloudflare 520 to 526 errors mean Cloudflare reached the edge fine but failed to get a good response from your origin server. Match the code to the failure: 520 empty response, 521 refused, 522 connection timeout, 523 unreachable, 524 response timeout, 525 TLS handshake failed, 526 invalid certificate.
- The visitor reached Cloudflare. The fault is between Cloudflare and your origin.
- Origin firewalls blocking Cloudflare IP ranges cause many 521 and 522 errors.
- 525 and 526 appear only with Full or strict SSL modes. Check the origin certificate.
What does each Cloudflare 52x error mean?
| Code | Meaning | Common causes | First fix |
|---|---|---|---|
| 520 | Unknown, empty or unexpected response | Origin crash, headers over 128 KB (often cookies), bad HTTP/2 setup | Check origin logs and HTTP/2 to origin |
| 521 | Origin is down or refuses connections | Web server offline, Cloudflare IPs blocked | Start the server, allow Cloudflare IPs, check port 80 or 443 |
| 522 | Connection to origin timed out | Firewall blocks or rate limits Cloudflare IPs, overloaded origin, wrong IP | Allow Cloudflare IPs, verify origin IP in DNS |
| 523 | Origin is unreachable | No route to the origin IP, wrong DNS record | Correct the A or AAAA record, check routing |
| 524 | Origin connected but did not respond in time | Long-running request or overloaded origin | Speed up or background the work, or move it off the proxy |
| 525 | TLS handshake with origin failed | No valid certificate, port 443 closed, no SNI, cipher mismatch | Install a certificate, open the port |
| 526 | Origin certificate cannot be validated | Expired, wrong hostname or missing intermediate, in Full (strict) | Install a valid or Cloudflare Origin CA certificate |
Which timeouts and limits matter?
How do you troubleshoot any 52x error?
- 01
Note the code, URL, time and cf-ray
Cloudflare asks for these when you contact your host or support. The time and time zone help match logs.
- 02
Test the origin directly
Request the origin by its IP, bypassing Cloudflare, or temporarily set the DNS record to DNS-only. If it fails too, the origin is the problem.
- 03
Allow Cloudflare IP ranges
Firewalls, .htaccess rules and iptables that rate limit or block Cloudflare are the most common cause of 522, and a frequent one for 521.
- 04
Check origin logs and load
Look for crashes, overload, and requests that never finish.
- 05
Match SSL mode to the origin
Flexible uses port 80. Full and Full (strict) use port 443 and need a valid certificate. Mismatches produce 521, 525 and 526.
- 06
Check intermediate devices
Load balancers, caches and firewalls between Cloudflare and the origin can fail without showing in the origin log.
Cloudflare 502 and 504 are different
A 502 or 504 branded as Cloudflare can mean a Cloudflare-side issue rather than your origin, while 520 to 526 point at the origin connection. Read the error page text and the cf-ray, and check the Cloudflare status page when many sites fail at once.
Common questions
What does Cloudflare error 522 mean?
Cloudflare timed out connecting to your origin. The request reached Cloudflare, but your server did not complete the TCP connection in time, most often because a firewall blocks or rate limits Cloudflare IP ranges, or the origin is overloaded or offline.
What is the difference between 521 and 522?
A 521 means the origin actively refused the connection or is down. A 522 means the connection attempt got no answer within the timeout. Refused points to a stopped service or blocked IPs. A timeout points to packet drops, overload or a wrong IP.
How long before Cloudflare returns a 524?
The default Proxy Read Timeout is 125 seconds on all plans. Enterprise plans can raise it. Requests that regularly run longer, such as big exports, should move to a DNS-only subdomain or a background job with polling.
What do Cloudflare 525 and 526 mean?
Both are TLS problems between Cloudflare and your origin, shown with Full or Full (strict) SSL. A 525 means the handshake failed, for example no certificate or port 443 closed. A 526 means the certificate cannot be validated, such as expired or wrong hostname.
Is a Cloudflare 52x error my visitors fault?
No. The visitor reached Cloudflare. The fault is between Cloudflare and the origin. Only the site owner or host can fix it, usually by checking the origin server, firewall rules and SSL settings.
How do I get alerted when my site returns a Cloudflare error?
Use an uptime monitor that checks from outside your network and alerts on 5xx responses. Because Cloudflare returns the error from its edge, a monitor sees the same page visitors do.
Keep reading
Watch the origin Cloudflare cannot reach
Aepto checks your site from up to six regions and alerts you when it starts returning errors.