Skip to content

Cloudflare error 520: what it means and how to fix it

By the ProxyOnly team · 16 Nov 2026 · 5 min read

Error 520 means Cloudflare reached the site's server and got an empty or unexpected reply. What causes it, how it differs from 521 to 526, and what to do.

Cloudflare error 520 means that Cloudflare connected to a website's own server and got back an empty, unknown or unexpected response. The page you see comes from Cloudflare, but the fault is behind it, on the site's server. Cloudflare's documentation for error 520 describes it as "web server returns an unknown error".

A 520 is not one of the standard status codes in the HTTP specification. Cloudflare uses the 52x range for its own reports about the connection between Cloudflare and the site's server, which it calls the origin. If you are a visitor there is little to do. If you run the site, the list of causes below usually leads to the answer.

How a site ends up behind Cloudflare

Cloudflare's DNS has a setting for each record called proxy status. When a record is Proxied, which the dashboard shows as an orange cloud, visitors connect to Cloudflare, and Cloudflare connects to the origin server for them. When a record is DNS-only, Cloudflare just answers with the server's real address and does not handle the traffic.

You can see the difference from a terminal. We ran these two commands against a site that uses Cloudflare:

$ curl -sI https://www.iana.org/ | grep -i -E '^(server|cf-ray):'
server: cloudflare
cf-ray: a5b7e2806a1c7ddd-AMS
$ dig +short www.iana.org
www.iana.org.cdn.cloudflare.net.
104.18.24.232
104.18.25.232

The server and cf-ray headers belong to Cloudflare. The addresses are Cloudflare's too: we checked that both fall inside the IPv4 ranges Cloudflare publishes at cloudflare.com/ips-v4. The site's real server is somewhere behind them, and a 520 is Cloudflare's report that this server answered badly. For the general idea of a proxy that sits in front of a server, see forward proxy vs reverse proxy.

What causes a 520

These are the causes in Cloudflare's documentation:

  • The origin crashes or is misconfigured. Cloudflare notes that 520 errors are common with certain PHP applications that crash the web server.
  • A firewall or security plugin on the origin blocks Cloudflare's IP addresses.
  • The origin sends response headers larger than 128 KB, often because of far too many cookies.
  • The response is empty or malformed, for example it has no status code or no body, or required headers are missing.
  • HTTP/2 is set up incorrectly on the origin. Cloudflare uses HTTP/2 to connect to servers that announce support for it. If the origin accepts that connection and then does not follow the protocol, the result is a 520.
  • Authenticated Origin Pulls is turned on in Cloudflare, but the origin is not set up for it.

The other 52x errors

Cloudflare uses neighbouring codes for more specific failures, and the code tells you where to look:

  • 521: the origin refused the connection. The server may be down, or a firewall is blocking Cloudflare.
  • 522: connection timed out. Cloudflare's documentation says it either got no reply to its connection attempt within 19 seconds, or no data within 90 seconds after connecting.
  • 523: the origin is unreachable. A network device between Cloudflare and the server has no route to the origin's address, or the address in DNS is wrong.
  • 524: Cloudflare connected, but the origin sent no HTTP response within 125 seconds by default.
  • 525: the secure handshake between Cloudflare and the origin failed.
  • 526: Cloudflare could not validate the origin's certificate, with the SSL/TLS mode set to Full (strict).
  • 530: Cloudflare could not resolve the origin's name. The body of the response contains a 1xxx error code, and that code has the detail.

These numbers are from Cloudflare's documentation as read on 16 November 2026, and they can change. 504 Gateway Timeout and 502 Bad Gateway describe the standard errors that look similar.

If you are a visitor

You cannot fix a 520 from your device, because the fault is on the site's server. What you can do:

  1. Reload after a few minutes.
  2. Check Cloudflare's own status page at cloudflarestatus.com if many sites are failing at once.
  3. Tell the site's owner. Include the time and the Cloudflare Ray ID printed at the bottom of the error page. It lets them find your request in their logs.
  4. See how to check if a website is down if you cannot tell whether the problem is yours.

If you run the site

Cloudflare's guide starts with your hosting provider and your server logs. These steps follow it.

  1. Read the origin's error logs for crashes around the time of the error. For PHP sites, look at the PHP and web server logs for memory and execution limits.
  2. Check whether the origin works without Cloudflare. As a temporary workaround, Cloudflare suggests setting the affected DNS record to DNS-only. This shows your origin's real address and removes Cloudflare's protection, so do it briefly and switch back. The next section describes a safer test.
  3. Make sure the origin's firewall and security plugins allow every Cloudflare range. Cloudflare publishes them at ips-v4 and ips-v6.
  4. Measure your response headers. curl -s -o /dev/null -w '%{size_header}\n' https://your-site.example/ prints the size of the headers in bytes. We ran it on a public site and got 1156. Anything near 128 KB points to cookie or header overload from a plugin or application.
  5. Check the HTTP/2 setup on the origin. If you cannot fix it, Cloudflare's documentation says you can switch off HTTP/2 to Origin under Speed, Settings, Protocol Optimization.
  6. Check Authenticated Origin Pulls on both sides.

Test the origin directly

A test that leaves DNS as it is requests the page straight from the origin, by pinning the host name to the server's address. Replace the address below with your server's real one:

curl -sv --resolve www.your-site.example:443:203.0.113.10 https://www.your-site.example/ -o /dev/null

The --resolve option makes curl use that address for the host name, so the TLS name and the Host header stay correct. We checked the syntax against a public site and it returned a normal 200. If the origin also answers badly to this request, the fault is on your server. If it answers well directly but fails through Cloudflare, look at the firewall, the headers and the HTTP/2 settings from the list above.

If the errors continue, Cloudflare Support asks for the full URLs, the cf-ray value, the output of /cdn-cgi/trace on your domain, and two HAR files, one with Cloudflare enabled and one with it temporarily disabled.

If a script or scraper gets a 520

A 520 is Cloudflare reporting that the site's server returned something unusable, so there is no setting on your side that fixes it. Wait, retry with growing delays and stop after a few attempts, as in 503 Service Unavailable. If a browser loads the same URL while your script keeps getting a 520, compare the two requests, and slow down. Do not hammer the page, because an origin that is already failing gets worse under load. A 520 alone does not show that you were blocked. Blocks usually arrive as a 403, a 429 or a challenge page, and why websites block IPs and proxies explains those.

Try it yourself

Create an account, add funds from US$1 and order a proxy in the country you need.

Keep reading