The WordPress Specialists

HTTP 520 Error: Cloudflare vs Fastly for Troubleshooting Unknown Web Server Errors

H

If you see HTTP 520, start at the origin server, not the CDN dashboard. Cloudflare uses 520 as a broad “unknown error” when the origin gives a response it cannot process, while Fastly usually surfaces similar failures as clearer 502, 503, or 504 errors.

TLDR: Cloudflare’s 520 error often means the origin closed the connection, sent malformed headers, crashed mid request, or returned something Cloudflare did not expect. Fastly does not commonly label this as “520”; it tends to point you toward backend connection, fetch, or timeout problems. For example, if 8% of checkout requests fail only through Cloudflare while direct origin tests succeed, compare CDN request headers, firewall rules, and origin connection limits before blaming the application code. In a real support case, that can cut troubleshooting from four hours to under one.

What HTTP 520 Really Means

An HTTP 520 error is mainly associated with Cloudflare. It means Cloudflare reached your origin server, but the origin returned an unexpected result. That result may be empty. It may be malformed. It may be interrupted before Cloudflare can make sense of it.

This is why 520 feels so irritating. It says “unknown,” but the cause is rarely magical. It is usually one of these:

  • The origin server reset the connection before sending a complete response.
  • Response headers were too large or formatted incorrectly.
  • A firewall, WAF, or security plugin blocked Cloudflare IPs.
  • PHP, Node.js, Python, or another app runtime crashed during the request.
  • The server hit connection, CPU, memory, or file descriptor limits.
  • HTTP/2, TLS, or keepalive behavior broke between the CDN and origin.

Honestly, it feels like a useless error at first. The page is down, the browser blames Cloudflare, and the origin logs may show nothing obvious. But that silence is also a clue. It can mean the request failed before the app logged it.

Cloudflare Troubleshooting: Where 520 Hides

Cloudflare sits between users and your server. When a browser requests a page, Cloudflare contacts the origin, receives the response, and passes it back. If that origin response breaks Cloudflare’s expectations, you may get the famous “Error 520: Web server is returning an unknown error.”

The fastest first test is simple:

  1. Pause Cloudflare or switch the DNS record to DNS only.
  2. Request the same URL directly from your browser and from curl.
  3. Check the exact timestamp in web server logs, application logs, and system logs.
  4. Compare headers between direct origin access and Cloudflare-routed access.

If direct origin access works but Cloudflare fails, inspect how your server treats Cloudflare traffic. Many 520 cases come from security controls that treat CDN requests as suspicious. ModSecurity rules, WordPress security plugins, rate limiters, bot filters, and country blocks can all cause pain.

Also check whether your origin trusts Cloudflare IP ranges. If it does not, logs may show every visitor as coming from Cloudflare. That can trigger rate limits quickly. A site with 300 visitors per minute may look like one IP hammering the server. Then the firewall blocks it. Then users see 520. Great fun, if your idea of fun is staring at logs at 2 a.m.

Fastly Troubleshooting: Similar Failure, Different Labels

Fastly handles origin failures differently. Instead of a broad 520 label, you are more likely to see 502 Bad Gateway, 503 Backend Unavailable, or 504 Gateway Timeout. These are not always nicer, but they usually hint at the failure class.

For example:

  • 502 often points to an invalid response from the backend.
  • 503 may mean the backend is unhealthy, overloaded, or unavailable.
  • 504 means the backend took too long to respond.

Fastly users should start with backend health checks, origin shielding, timeout settings, and service logs. Fastly’s real-time logging is especially useful when configured well. You can stream request data to tools like Datadog, BigQuery, S3, or an ELK stack and see patterns quickly.

The annoyance is setup. If logging was not configured before the incident, you may have less detail than you want. Expect to lose 20 minutes recreating traffic and comparing headers if nobody saved request IDs or backend response metadata.

Cloudflare vs Fastly: Key Differences During an Outage

Cloudflare is often easier for smaller teams to deploy. It gives a friendly dashboard, DNS controls, WAF tools, caching rules, and SSL settings in one place. But 520 can be vague. It may force you to work backward from an unknown origin failure.

Fastly tends to suit teams that want deep control over edge behavior. Its VCL-based configuration, observability options, and request handling tools can be very precise. But it assumes you know what you are looking at. Misconfigured backends, shielding, or health checks can create confusing errors too.

Area Cloudflare Fastly
Unknown origin failure Often shown as 520 Usually 502, 503, or 504
Beginner friendliness High Medium
Error clarity Mixed for 520 Often more specific
Log power Good with proper plan and setup Very strong when configured
Common fix area Origin firewall, headers, app crashes Backend health, timeout, VCL, origin response

Practical Checklist for a Cloudflare 520

Use this order. It saves time.

  1. Confirm the error scope. Is it one URL, one region, one browser, or the whole site?
  2. Test the origin directly. Use curl with the host header: curl -I https://origin-ip -H "Host: example.com".
  3. Check server logs by timestamp. Look at Nginx or Apache logs, app logs, PHP-FPM logs, and kernel messages.
  4. Review headers. Remove oversized cookies, broken redirects, and odd custom headers.
  5. Check firewall rules. Allow current Cloudflare IP ranges.
  6. Inspect resource limits. Look for memory spikes, worker exhaustion, and connection caps.
  7. Disable recent changes. Roll back new WAF rules, plugins, deployments, or TLS changes.

Large cookies are a sneaky cause. If your app stores too much session data in cookies, request headers can grow fast. Cloudflare may reject or mishandle the response path when the origin behaves badly around those headers. Trim cookies. Move session data server-side. Your future self will be less annoyed.

Practical Checklist for Fastly Origin Errors

For Fastly, focus on the backend path:

  • Check backend health status in the Fastly control panel or API.
  • Review timeout values for first byte, connect, and between bytes.
  • Inspect VCL changes that alter host headers, TLS settings, or backend selection.
  • Compare shielded and unshielded behavior if origin shielding is active.
  • Stream logs and filter by status code, backend name, and request path.

If a Fastly service returns 503 for only one backend, test that backend from outside Fastly. Then test from a location close to the Fastly shield. A backend may look healthy from your office but fail from the POP or shield region that matters.

Which CDN Is Better for Unknown Web Server Errors?

For pure troubleshooting clarity, Fastly often has the edge when logging is already configured. Its error categories and real-time log streaming can make backend failures easier to group and measure. A team can see that 92% of failures hit one backend, or that timeouts rose after a new deploy.

For speed and convenience, Cloudflare is hard to beat. Many fixes are close at hand: WAF settings, SSL mode, DNS proxy status, cache rules, and security events. The weak spot is the 520 label itself. It compresses many possible origin failures into one bucket.

The best choice depends on your team. If you want a broad security and performance platform with quick setup, Cloudflare is attractive. If your team wants fine-grained edge control and strong request logging, Fastly may fit better.

Final Takeaway

A 520 is not really a Cloudflare problem until proven otherwise. Treat it as an origin response failure first. Pull logs, test the origin directly, compare headers, and check firewalls before changing random CDN settings.

Fastly reports similar problems with more familiar HTTP codes, but the root causes are often the same: broken origin behavior, timeouts, blocked CDN IPs, bad headers, or overloaded servers. The winning move is not guessing. It is matching the CDN error to origin evidence as quickly as possible.

About the author

Ethan Martinez

I'm Ethan Martinez, a tech writer focused on cloud computing and SaaS solutions. I provide insights into the latest cloud technologies and services to keep readers informed.

By Ethan Martinez
The WordPress Specialists