Skip to the content

Contact usFree tools · No signup · Files stay on your device

Website Tools

Cloudflare errors 520, 521 and 522: what they mean

Cloudflare errors 520, 521 and 522: what they mean

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

  1. Check that the web server is running, and restart it if not. Look at its error log for a crash.
  2. Allow Cloudflare's address ranges in the server firewall and in any security plugin.
  3. 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, iptables or 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

  1. Check the origin is online and not out of memory or workers.
  2. 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.
  3. 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

  1. Read the origin's error logs around the time of the error. Look for crashes, memory errors or fatal PHP errors.
  2. Reduce the size of cookies and response headers.
  3. 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

  1. 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.
  2. 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.
  3. Check whether it is down for everyone. The Website Status Checker shows whether a site is up, answering with errors or down, and why.
  4. 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.

Frequently asked questions

Are 520, 521 and 522 official HTTP status codes?
No. They are Cloudflare's own codes for problems between Cloudflare and your origin server, so no RFC defines them. The HTTP Status Code Lookup lists them under Unofficial.
Is the problem with Cloudflare or with my server?
Almost always with your server or its firewall. These errors mean Cloudflare itself is working and could not get a proper answer from the origin, so the place to look is your hosting, not Cloudflare.
What is the quickest test to see if my origin is the problem?
Set the DNS record to DNS only, the grey cloud, for a few minutes. If the site then loads, the origin works and the issue is how it handles Cloudflare's connections, usually a firewall. Switch the record back to proxied afterwards.
Why does 522 happen when the site works for me?
Your own connection may reach the server while Cloudflare's addresses are blocked or rate limited by the server's firewall. Many hosts block unfamiliar addresses that make many requests, and every visitor's request arrives from Cloudflare's addresses.
Do I need to contact Cloudflare support?
Check your origin first. If the origin looks fine and the error persists, Cloudflare's documentation asks you to send the full URL, the cf-ray value shown on the error page, and the output of /cdn-cgi/trace.
Found this useful? Share it

Tools in this guide

Main tool

HTTP Status Code Lookup

Look up any HTTP status code to see what it means, why it happens, how to fix it and how it affects SEO — including unofficial codes from Cloudflare.

Open tool

HTTP Header Checker

See the exact status code and response headers a URL returns, follow its redirects, and get a security-header grade with clear fixes.

Open tool

Website Status Checker

Find out in seconds whether a site is up, answering with errors, or down — and why, from DNS through to the server's response.

Open tool

DNS Lookup

Query a domain's DNS records live from a public resolver of your choice.

Open tool

Back to all guides & blog