Cloudflare error · 520
Cloudflare error 520
Cloudflare error 520 means Cloudflare reached your origin and could not make sense of the response. The origin sent nothing, sent a reset, or sent bytes that are not a valid HTTP response. 520 is Cloudflare’s code, not a registered HTTP status.
HTTP status codes explained · the longer reference on the blog.
What 520 means
From the visitor’s side it looks like any other edge error page. From Cloudflare’s side the TCP connection to the origin worked, and the HTTP conversation did not. That puts 520 next to a classic 502 Bad Gateway. A standard proxy would often call the same failure 502. Cloudflare labels this pattern 520.
The origin web server is the place to look: a crash while writing the response, a header that violates HTTP, a response so large the origin aborts, or an empty reply from a misconfigured upstream behind your own nginx. Cloudflare’s own docs describe 520 as an unknown, empty, or invalid response from the origin.
Common causes
The origin closed the connection with no status line
A worker crashed, a CGI script printed nothing, or a backend reset the socket. Cloudflare has a connection and no HTTP message to forward.
The response is not valid HTTP
A header with a raw newline, a status line missing the reason phrase in a strict parser, or an upstream speaking a different protocol than Cloudflare expects.
A second proxy in front of the app is failing
Cloudflare talks to nginx or Caddy, and that local proxy fails to talk to the app. You may see 520 at the edge and 502 in the local error log. Fix the local upstream.
The origin is rejecting or mangling Cloudflare’s request
A module chokes on the headers Cloudflare adds, or a firewall resets the connection after the handshake. The edge reports that as an unknown response.
How to fix it
Reproduce against the origin, not only the orange-clouded host
Request the origin by its direct hostname or with the DNS record set to DNS-only for a test. If the origin already resets or returns garbage, Cloudflare is reporting that faithfully.
Read the origin error log at the same second
Look for upstream resets, worker crashes, and “upstream sent too big header.” Those are origin bugs even though the visitor saw a Cloudflare page.
Strip the failure down to a static file
Serve a tiny static file from the same vhost. If that returns 200 through Cloudflare and the app URL returns 520, the application response is the broken one.
Capture one raw response
From a host that can reach the origin, inspect the status line and headers. Invalid header bytes are a common 520. Fix the app that writes them.
Is it your site, or just you?
Error 520 is generated at Cloudflare’s edge, so every visitor who goes through that proxy can see it. A phone on cellular data is enough to confirm it is not a browser extension.
The homepage checker follows the public DNS, so it goes through Cloudflare the same way a visitor does. HTTP 520 from the checker means the edge is returning that page to our network too. Then check the origin directly to see whether the bad response starts there.
How to monitor for 520
Monitor the public hostname and expect 200. A 520 fails the check and alerts after a second consecutive failure, with the status in the alert. Also keep a check on a static file if you want to know whether the whole vhost is failing or only the application route.
The checker on the ismysiteup homepage requests the URL from our servers and shows the HTTP status, response time, and SSL details. No account is required, and that checker allows 5 checks per hour from the same network. A free account watches 5 URLs, each checked every 10 minutes, and sends alerts on WhatsApp, Telegram, Slack, or email. A monitor expects HTTP 200 unless you set a different expected status (100–599). One failed check is confirmed with a second check before the first alert, and a later success sends a recovery alert. Pro (every 5 minutes) and Business (every minute) are listed on the pricing page; paid checkout is not open yet.
Related status codes
- 502Bad GatewayA proxy received an invalid response from the server behind it.
- 500Internal Server ErrorThe application failed while handling a request it understood.
- 521Web Server Is DownCloudflare reached the origin IP, and the origin refused the connection.
- 522Connection Timed OutCloudflare tried to open TCP to the origin and the handshake never finished.
FAQ
Is Cloudflare error 520 an official HTTP status?
No. It is Cloudflare’s own error. The origin usually did not intend to send 520. Cloudflare chose that page because the origin’s response was empty, reset, or not valid HTTP.
How is 520 different from 502?
They describe the same kind of failure: a gateway got an unusable reply. 502 is the standard code. 520 is the code Cloudflare shows for that case.
Does 520 mean Cloudflare is down?
Cloudflare was able to accept the visitor and contact the origin. The unknown part is the origin’s reply. Start on the origin, including any proxy installed there.