أهم النقاط
- 52x errors mean Cloudflare couldn't get a proper response from your origin server.
- The site is behind Cloudflare, but the problem is almost always at the origin.
- Allowlist Cloudflare's IP ranges in your server firewall.
When a site uses Cloudflare, visitors connect to Cloudflare, and Cloudflare connects to your server (the origin). The 52x family means that second connection failed.
| Error | Meaning | Usual cause |
|---|---|---|
| 520 | Unknown error | Origin returned an empty or invalid response, or crashed mid-request |
| 521 | Web server is down | Origin refused the connection — web server stopped or firewall blocking |
| 522 | Connection timed out | Origin didn’t answer in time — overload, wrong IP, or dropped packets |
| 523 | Origin unreachable | DNS record in Cloudflare points to an address that can’t be routed |
| 524 | A timeout occurred | Origin accepted the connection but took over 100 seconds to respond |
Fix steps
- Check the origin is running. On a VPS:
systemctl status nginx(orapache2) andsystemctl status php8.3-fpm. - Verify the origin IP. In Cloudflare DNS, the
Arecord must be your server’s current IP. - Allow Cloudflare through the firewall. Firewalls and security plugins sometimes block Cloudflare’s IPs because all traffic appears to come from them. Allow the published ranges at
cloudflare.com/ips. - Check ports. Cloudflare connects on 80 for HTTP and 443 for HTTPS. Both must be open.
- Set SSL to Full (strict) and install a valid certificate (or a Cloudflare Origin Certificate) on the server.
- For 520s, read the error log. Responses with huge headers or crashes in PHP produce 520.
- For 524s, move slow jobs (exports, imports) to background tasks or a subdomain that isn’t proxied.
الأسئلة الشائعة
How do I test my origin directly?
Temporarily pause Cloudflare for the site, or use curl with --resolve to send a request straight to your server's IP while keeping the hostname.
What SSL mode should I use?
Full (strict), with a valid certificate on the origin. Flexible mode often causes redirect loops and leaves traffic to your server unencrypted.