You open your site and instead of your page there is a Cloudflare error with a number: 520, 521 or 522. The number is a clue, and it points in a different direction each time. The short version: Cloudflare is fine, it tried to reach your server (the "origin"), and something went wrong on that last step. You can look any of these up in the free HTTP Status Code Lookup, which lists 520 to 527 with causes and fixes. This post explains the first three and gives you an order for finding the cause.
The three errors in one table
| Error | What Cloudflare is telling you | Most common cause |
|---|---|---|
| 520 | The origin answered with something empty, unknown or unexpected | The app crashed or sent a broken response |
| 521 | The origin refused the connection | The web server is stopped, or blocking Cloudflare |
| 522 | The connection to the origin timed out | A firewall dropping Cloudflare's addresses, or an overloaded server |
Remember that none of these are real HTTP status codes. They are Cloudflare's names for what went wrong between its edge and your server, which is why the lookup marks them Unofficial.
521: web server is down
Cloudflare tried to open a connection and your server said no. Think of knocking on a door and finding it locked.
Likely causes
- The web server (nginx, Apache, LiteSpeed) is stopped or crashed.
- The server firewall blocks Cloudflare's addresses.
- The server is not listening on the port Cloudflare is using. Cloudflare's documentation says port 80 for Flexible SSL, and port 443 for Full and Full (strict).
What to try
- Check that the web server is running, and restart it if not. Look at its error log for a crash.
- Allow Cloudflare's address ranges in the server firewall and in any security plugin.
- If you use Full or Full (strict), confirm the origin really serves HTTPS on port 443.
522: connection timed out
Here the door is not refused: nobody answers. Cloudflare sent its request and heard nothing back in time. Cloudflare's documentation says it waits about 19 seconds for the first reply to a connection attempt, and about 90 seconds for data after the connection is open.
Likely causes
- Cloudflare's addresses are rate limited or blocked by the firewall,
.htaccess,iptablesor a security tool. Cloudflare's own page calls this the most common cause. - The origin is offline or overloaded and drops connections.
- The origin IP address in Cloudflare's DNS is wrong, for example after a server move.
- Keepalives are switched off on the origin.
What to try
- Check the origin is online and not out of memory or workers.
- Open the DNS tab in Cloudflare and compare the A record with the IP your host gave you. The DNS Lookup shows what the world sees.
- Allow all of Cloudflare's address ranges at the firewall. If you want to restrict visitors by country, do it in Cloudflare rather than by blocking its addresses.
520: unknown error
Cloudflare connected but received a response it could not use. This one is the widest, and it often means the application behind the web server failed.
Likely causes
- The origin crashed or reset the connection part-way through the response. Cloudflare's page says certain PHP applications often trigger it.
- The response headers are too large. Cloudflare's page gives 128 KB as the limit, usually from too many cookies.
- An empty or malformed response with no status code.
- A firewall or security plugin blocking Cloudflare.
- A faulty HTTP/2 setup at the origin.
- Authenticated Origin Pull switched on at Cloudflare, but not set up on the server.
What to try
- Read the origin's error logs around the time of the error. Look for crashes, memory errors or fatal PHP errors.
- Reduce the size of cookies and response headers.
- If you use HTTP/2 to the origin and the errors continue, Cloudflare suggests turning "HTTP/2 to Origin" off to test, under Speed, Settings, Protocol Optimization.
A quick way to tell them apart
- Switch the DNS record to DNS only (grey cloud) for a few minutes. If the site loads, the server works without Cloudflare, so look at firewalls and Cloudflare's address ranges. If it still fails, the server itself is the problem. Switch back to proxied when you finish.
- Check what the URL returns. Paste the address into the HTTP Header Checker. A status of 520, 521 or 522 appears in the Status box, and the response headers show that the answer came from Cloudflare. The check is made from our server, so it also tells you the site is failing for outsiders, not only for you.
- Check whether it is down for everyone. The Website Status Checker shows whether a site is up, answering with errors or down, and why.
- Note the Ray ID. The error page shows one. Keep it if you need support.
Other Cloudflare errors that look similar
- 523 Origin Is Unreachable: Cloudflare cannot find a route to the server, usually a wrong IP in DNS or a routing problem at the host.
- 524 A Timeout Occurred: Cloudflare connected and the origin was too slow to answer (Cloudflare documents a default timeout of 125 seconds). Move long jobs, such as big imports, to the background.
- 525 and 526: the secure connection to the origin failed or its certificate is invalid. Install a valid certificate on the server, and see the SSL Checker for how certificates and chains are judged.
- 530: appears alongside a 1xxx error such as 1016, an origin DNS problem. The number on the page explains the real cause.
Do not confuse these with 502, 503 and 504, which are real HTTP codes. The complete HTTP Status Code Lookup guide explains how the standard 5xx codes differ.
What visitors can do
Not much. These errors come from the site's server. Wait a few minutes and reload, and if it continues, tell the site owner, ideally with the Ray ID from the page.
Quick checklist
- 521 means refused: start the server and allow Cloudflare.
- 522 means no answer: check the firewall, the origin IP and the load.
- 520 means a bad answer: read the application's error log.
- Test with DNS only for a few minutes to split Cloudflare from the origin.
- Keep the Ray ID for any support request.



