Error 520: Web Server Returned an Unknown Error (Cloudflare)
Updated Free mock REST & WebSocket APIs
Error 520 Web Server Returned an Unknown Error — Cloudflare got an empty, unknown or unexpected response from the origin server.
- Class
- 5xx Server Error
- Defined in
- Unofficial (Cloudflare)
- Official
- No — Cloudflare-specific
- Cacheable by default
- No (unless Cache-Control/Expires say so)
- Safe to retry
- Yes, after a delay (respect Retry-After)
Try it: get a real 520 response
Our test endpoint answers every request with 520 Web Server Returned an Unknown Error.
curl -i https://mockfox.dev/api/status/520Use it in tests, health-check monitors or to see how your client handles a 520. Add ?delay=2000 to slow it down.
What does error 520 mean?
Error 520 "Web server is returning an unknown error" is a Cloudflare-specific status. Cloudflare reached your origin server, but the origin returned something Cloudflare couldn't interpret: an empty response, a connection reset, or a response with invalid or oversized headers.
It's a catch-all for unexpected origin behaviour, so the fix is always on the origin side.
When is 520 used?
- The origin crashes or resets the connection after Cloudflare connects.
- Response headers exceed Cloudflare's limit (32 KB total headers, often from huge cookies).
- The origin returns an empty reply, a malformed HTTP response, or HTTP/2 errors.
- A firewall or security plugin on the origin kills connections from Cloudflare IPs.
Common causes of error 520
- Application crash or PHP-FPM/Node process dying.
- Very large
Set-Cookieor other headers. - Origin firewall/rate limiting blocking Cloudflare IP ranges.
- Origin web server misconfiguration (e.g. wrong protocol on the port Cloudflare connects to).
How to fix 520 Web Server Returned an Unknown Error
If you're visiting the site
- Reload in a minute; if it persists, the site owner needs to fix their server. There's nothing on your device causing it.
If you run the site or API (developers)
- Bypass Cloudflare (
curl -svo /dev/null --resolve example.com:443:ORIGIN_IP https://example.com/) to see what the origin really returns. - Check origin web-server and application error logs at the timestamps of the 520s.
- Allow all Cloudflare IP ranges (cloudflare.com/ips) in your firewall and rate limiting.
- Reduce header size (cookies) below 32 KB; check for responses with no body and no Content-Length.
- Open a ticket with the Ray ID if the origin looks healthy.
Returning or handling 520: server examples
Diagnose (bypass Cloudflare)
curl -sv --resolve example.com:443:203.0.113.10 https://example.com/ -o /dev/null # Look for "Empty reply from server", resets, or huge headers
nginx (restore real IPs)
# Trust Cloudflare as proxy so logs/rate limits see the visitor IP set_real_ip_from 173.245.48.0/20; # …add all ranges from cloudflare.com/ips real_ip_header CF-Connecting-IP;
Example 520 response
HTTP/2 520 server: cloudflare cf-ray: 8d2f1a3b4c5d6e7f-AMS content-type: text/html; charset=UTF-8
Related status codes
- 502 Bad GatewayA gateway or proxy got an invalid response from the upstream server.
- 521 Web Server Is DownCloudflare couldn't connect to the origin because it refused the connection.
- 500 Internal Server ErrorThe server hit an unexpected condition that prevented it from fulfilling the request.
Related tools
Frequently asked questions
Is error 520 a Cloudflare problem?
Almost always the origin server's problem. Cloudflare is reporting that your server answered with something invalid or nothing at all.
How do I fix Cloudflare error 520?
Check origin logs for crashes, allow Cloudflare IPs, shrink oversized headers/cookies, and test the origin directly (bypassing Cloudflare) to reproduce the bad response.
What is the difference between 520 and 502?
Both mean a bad response from upstream. 520 is Cloudflare's own, more specific code for an unknown or empty origin response; a 502 behind Cloudflare is usually generated by your origin's proxy.