Skip to content

Tutorials Troubleshooting & errors Intermediate1 min read

How to Fix Cloudflare Errors 520, 521, 522 and 523

What Cloudflare 52x errors mean and how to fix them: origin server down, firewall blocking Cloudflare IPs, timeouts, wrong DNS or SSL mode.

By ZSOLNET Editorial Team Updated

Key takeaways

  • 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.

ErrorMeaningUsual cause
520Unknown errorOrigin returned an empty or invalid response, or crashed mid-request
521Web server is downOrigin refused the connection — web server stopped or firewall blocking
522Connection timed outOrigin didn’t answer in time — overload, wrong IP, or dropped packets
523Origin unreachableDNS record in Cloudflare points to an address that can’t be routed
524A timeout occurredOrigin accepted the connection but took over 100 seconds to respond

Fix steps

  1. Check the origin is running. On a VPS: systemctl status nginx (or apache2) and systemctl status php8.3-fpm.
  2. Verify the origin IP. In Cloudflare DNS, the A record must be your server’s current IP.
  3. 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.
  4. Check ports. Cloudflare connects on 80 for HTTP and 443 for HTTPS. Both must be open.
  5. Set SSL to Full (strict) and install a valid certificate (or a Cloudflare Origin Certificate) on the server.
  6. For 520s, read the error log. Responses with huge headers or crashes in PHP produce 520.
  7. For 524s, move slow jobs (exports, imports) to background tasks or a subdomain that isn’t proxied.

Frequently asked questions

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.

Share X LinkedIn Facebook

Log in to your account

Manage your domains, hosting and invoices in one place.

Secure connection straight to the ZSOLNET client area.

No account yet?