Cloudflare Error 520: Web Server Returned an Unknown Error

Cloudflare connected to your origin, but the origin returned an empty, unknown or invalid response.

Seen on: Cloudflare

Meaning

520 is Cloudflare’s catch-all for “the origin answered with something I can’t use” — the connection reset, the response was empty, or headers were invalid/too large. It’s an origin problem, not a Cloudflare outage.

Common causes

  • Origin application crashed mid-response
  • Response headers exceed Cloudflare’s 128 KB limit (huge cookies)
  • Empty response or connection reset by origin
  • Firewall on origin resetting connections from Cloudflare IPs
  • Invalid HTTP response from the application

⚡ Quick fix

  1. Check origin web server and app logs at the time of the Ray ID
  2. Temporarily pause Cloudflare (or hit origin IP directly) to reproduce
  3. Reduce cookie/header size
  4. Allow-list Cloudflare IP ranges in the origin firewall

Detailed fix by platform

Cloudflare

  1. Collect the Ray ID from the error page; compare timestamps with origin logs. Ensure the origin isn’t rate-limiting Cloudflare IPs.

Code examples

Bypass Cloudflare to test origin

bash
curl -svo /dev/null --resolve example.com:443:203.0.113.10 https://example.com/

Replace 203.0.113.10 with your origin IP.

How to diagnose

  1. Origin logs — Errors at the Ray ID timestamp?
  2. Direct request — Does origin respond correctly without Cloudflare?
  3. Headers — Response headers/cookies too large?
  4. Firewall — Cloudflare IPs allowed?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.