520
HTTPERRORNotable5xx Server Error (Cloudflare)HIGH confidence

Web Server Returned an Unknown Error

Production Risk

High — all traffic behind Cloudflare is affected when the origin returns empty responses.

What this means

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.

Why it happens
  1. 1The origin server crashed or restarted while processing the request.
  2. 2The origin sent an empty response (no headers, no body).
  3. 3A PHP fatal error caused the script to terminate without sending a response.
  4. 4The origin server's response was corrupted in transit.
  5. 5A firewall on the origin blocked Cloudflare's IP and sent back a non-HTTP response.
How to reproduce

The origin web server encounters a fatal error mid-response and closes the connection without finishing.

trigger — this will error
trigger — this will error
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 origin server error logs
# 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.

Allowlist Cloudflare IP ranges on the origin firewall
# 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.

What not to do

Do not disable Cloudflare to test origin

Instead, use Cloudflare's 'Development Mode' or add your IP to Page Rules bypass to test directly.

Version notes
Cloudflare

Cloudflare-specific. Check Cloudflare's dashboard for additional diagnostics.

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All HTTP errors