Web Server Returned an Unknown Error
Production Risk
High — all traffic behind Cloudflare is affected when the origin returns empty responses.
520 is a Cloudflare-specific error indicating that the origin server returned an empty, unknown, or unexpected response to Cloudflare. Cloudflare cannot interpret the response and returns 520 to the client.
- 1The origin server crashed or restarted while processing the request.
- 2The origin sent an empty response (no headers, no body).
- 3A PHP fatal error caused the script to terminate without sending a response.
- 4The origin server's response was corrupted in transit.
- 5A firewall on the origin blocked Cloudflare's IP and sent back a non-HTTP response.
The origin web server encounters a fatal error mid-response and closes the connection without finishing.
GET /api/data HTTP/1.1 Host: example.com # Origin crashes; Cloudflare gets empty TCP close
expected output
HTTP/1.1 520 Web Server Returned an Unknown Error
Fix 1
Check origin server error logs
WHEN Always — 520 means the origin behaved unexpectedly.
# Check application logs tail -f /var/log/nginx/error.log tail -f /var/log/apache2/error.log journalctl -u myapp --since '5 minutes ago'
Why this works
Identifies the root cause — crash, OOM, PHP error, etc.
Fix 2
Allowlist Cloudflare IP ranges on the origin firewall
WHEN The origin firewall is blocking Cloudflare.
# Cloudflare IP ranges: https://www.cloudflare.com/ips/ # Add these to your origin firewall allowlist
Why this works
Ensures Cloudflare can reach the origin server without being blocked.
✕ Do not disable Cloudflare to test origin
Instead, use Cloudflare's 'Development Mode' or add your IP to Page Rules bypass to test directly.
Cloudflare-specific. Check Cloudflare's dashboard for additional diagnostics.
Cloudflare 5xx error documentation
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#520 ↗Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev