Cloudflare error 522: connection timed out
Websites & Hosting — A2Z Skills
By Devchandra Shrestha, 2026-11-13
https://a2zskillsewa.com/cloudflare-error-522-explained/
Short answer: Error 522 means Cloudflare could not complete a connection to your origin in time: either no SYN+ACK arrived within 19 seconds of its SYN, or an established connection did not acknowledge the request within 90 seconds. Blocked Cloudflare IP ranges are the most common cause.
A 522 is a report about a connection, not about your application. Cloudflare
tried to reach the server behind your domain, waited, and gave up before
anything was served. That means the page a visitor sees was generated at
Cloudflare's edge, so your origin logs may show nothing at all.
This explanation covers a hostname proxied through Cloudflare to an origin you
or a hosting provider operates. More hosting explanations are in
Websites & Hosting (/topics/websites-hosting/). If the hostname is served by a
Worker rather than a web server, the deployment states are covered in
Cloudflare Workers custom domain not working (/cloudflare-workers-custom-domain-not-working/).
Two different timeouts produce the same number
Cloudflare's Error 522 documentation (https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-522/)
describes two timeouts, separated by whether a TCP connection was ever
established.
Before a connection exists, Cloudflare sends a SYN and waits for a SYN+ACK. If
none arrives within 19 seconds, the request fails as a 522. Cloudflare retries
the SYN during that window on documented backoff intervals of 1, 1, 1, 1, 1, 2,
4 and 8 seconds.
After a connection exists, Cloudflare sends its resource request and waits for
an acknowledgment. If none arrives within 90 seconds, that also fails as a 522.
The distinction is worth keeping because it separates "nothing answered the
door" from "something answered and then stopped responding". The error code does
not tell you which of the two happened.
Blocked Cloudflare IP ranges are the documented first suspect
Cloudflare lists Cloudflare IP addresses (https://www.cloudflare.com/ips/)
being rate limited or blocked in .htaccess, iptables or a firewall as the
most common cause, and says to confirm the hosting provider allows all
Cloudflare IP ranges.
This is the cause that catches people who tightened a firewall for unrelated
reasons. A rule that allows only a handful of addresses, or one that rate limits
aggressively, blocks the proxy rather than an attacker. Cloudflare's own
suggestion for restricting traffic by location is a
WAF custom rule (https://developers.cloudflare.com/waf/custom-rules/use-cases/block-by-geographical-location/)
at the edge instead of a rule at the origin.
The documentation lists four more origin-side causes:
- An overloaded or offline origin web server dropping incoming requests.
- Keepalives (http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html) disabled
at the origin web server.
- The origin IP address in the Cloudflare DNS app not matching the address
currently provisioned by the hosting provider.
- Packets being dropped at the origin web server.
The third one is quiet and common after a server migration. The record still
resolves, so DNS looks healthy, and nothing is listening at the address it
returns. That is a different problem from a record that has not finished
publishing, which is covered in
DNS propagation (/dns-propagation-explained/).
A Worker can produce a 522 against itself
Cloudflare documents that a Worker on a
Custom Domain (https://developers.cloudflare.com/workers/configuration/routing/custom-domains/)
performing a fetch to its own hostname causes a 522. The request loops back to
the same Worker rather than reaching an origin.
The documented alternatives are a
Route (https://developers.cloudflare.com/workers/configuration/routing/),
targeting a different hostname, or enabling the
global_fetch_strictly_public (https://developers.cloudflare.com/workers/configuration/compatibility-flags/#global-fetch-strictly-public)
compatibility flag.
Origin Rules (https://developers.cloudflare.com/rules/origin-rules/) can
produce the same error for a related reason: the resulting hostname has to be
resolvable. Cloudflare's example is an Origin Rule pointing at a Worker route
whose hostname is an A record for a reserved address such as 100:: or
192.0.2.0.
521, 522, 523 and 524 answer different questions
| Error | Cloudflare's description | What had already happened |
| ----- | ------------------------ | ----------------------------------------- |
| 521 | Web server is down | The origin refused the connection |
| 522 | Connection timed out | The connection did not complete in time |
| 523 | Origin is unreachable | The origin could not be reached |
| 524 | A timeout occurred | Cloudflare connected; no response in time |
The 524 case is the one most often confused with 522. Cloudflare's
Error 524 page (https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-524/)
says it means Cloudflare connected successfully and the origin did not provide
an HTTP response before the default 125 second Proxy Read Timeout. A 524 can
also come from the 30 second Proxy Write Timeout, which is 6.5 seconds for
Cloudflare Images (https://developers.cloudflare.com/images/) and cannot be
adjusted.
So a 524 points at slow work on a server that is reachable. A 522 points at the
connection never getting far enough for the server's speed to matter.
The timeout values are documented, and they are not a complete list
Cloudflare's connection limits reference (https://developers.cloudflare.com/fundamentals/reference/connection-limits/)
publishes the figures behind these errors: 19 seconds for TCP connection
establishment and 90 seconds for request acknowledgment, both reported as 522,
against 125 seconds for Proxy Read Timeout and 30 seconds for Proxy Write
Timeout, both reported as 524. The Proxy Read Timeout is adjustable on
Enterprise zones; the others are not.
The same page is careful about what those numbers prove. It states that a
connection timeout does not by itself identify which operation timed out or what
caused it, that the two TCP rows are not an exhaustive list of every operation
that can produce a 522, and that neither figure is a universal budget covering
TCP and TLS setup together.
That last point has a practical consequence. A timeout while TLS is still
pending can be reported as 522 rather than 525, so a 522 does not rule out a
certificate or handshake problem. The modes that govern that leg are compared in
Cloudflare SSL modes (/cloudflare-ssl-modes-explained/).
Where to look before contacting anybody
Cloudflare suggests Origin Analytics (https://developers.cloudflare.com/speed/origin-analytics/)
for checking TCP connection failures to the origin, and notes that a high
failure rate on specific paths in the Top endpoints table points at a
path-specific problem rather than a general origin outage.
For a 520, which overlaps in feel, Cloudflare also documents reading
OriginResponseStatus in Logpush http_requests data, and warns against
concluding the origin returned a 5xx from OriginResponseStatus = 0 alone:
check CacheStatus first, because a cache hit means Cloudflare never contacted
the origin.
If the cause is not at the edge, Cloudflare's guidance is to contact the hosting
provider with the
error details it asks for (https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/#required-error-details-for-hosting-provider).
A screenshot showing the Ray ID and the time in UTC is the part that lets
somebody find the request in a log.
Questions and answers
Does error 522 fix itself?
Sometimes, because one documented cause is an overloaded or offline origin dropping incoming requests, and that can pass. The other documented causes do not pass on their own. Blocked Cloudflare IP ranges, a stale origin IP address in the DNS app and disabled keepalives all stay broken until somebody changes them.
What is the difference between error 522 and error 524?
A 522 means the connection itself did not complete in time. A 524 means Cloudflare connected successfully and the origin then failed to return a response within the Proxy Read Timeout, 125 seconds by default. One is about reaching the server, the other about the server answering.
Can a Cloudflare Worker cause a 522 on its own domain?
Yes. Cloudflare documents that a Worker on a Custom Domain performing a fetch to its own hostname produces a 522. The documented options are a Route, targeting another hostname, or enabling the global_fetch_strictly_public compatibility flag.
Does a 522 mean my origin is definitely down?
No. Cloudflare notes that a connection timeout does not by itself identify which operation timed out or what caused it. A timeout while TLS is still pending can be reported as 522 rather than 525, and the two TCP timeouts are not an exhaustive list of what can produce the error.