Back to blog

How to Troubleshoot Cloudflare 522 Errors: Trace the Edge-to-Origin Connection First

CdnChart EngineeringPublished on 2026-11-3016 min read4,171
How to Troubleshoot Cloudflare 522 Errors: Trace the Edge-to-Origin Connection First

When troubleshooting Cloudflare 522 errors, start with the common edge-to-origin connection or acknowledgment timeout scenarios described here, rather than clearing browser caches, changing website code, or increasing application execution timeouts. For a website delivered through Cloudflare's proxy, receiving a 522 page generally means that the client has at least received an HTTP response from the edge for that request. The questions to investigate are: Which origin endpoint did the edge try to connect to? Did that endpoint receive the connection attempt? Could return packets get back? And, once the connection was established, was the data acknowledged promptly?

The first practical step is to capture the failure time, request URL, request identifier in the response, and origin-side evidence together, then run a direct-origin comparison that preserves Host and TLS SNI. A successful direct connection proves only that the test machine could reach the specified endpoint; it does not prove that Cloudflare could reach it. Likewise, an absence of application logs does not directly prove that Cloudflare sent no request. Either misconception can take the investigation away from the actual problem.

This article covers the conventional origin connection path when Cloudflare acts as a website reverse proxy/CDN. It does not treat Workers custom subrequests, Tunnel, object storage, or other connectivity products as the same failure path. If your architecture includes these components, first mark where they sit, then identify which component established the connection that timed out. Cloudflare's CDN product overview describes it as a reverse proxy, which is the starting point for distinguishing client connections from origin connections.

Map the Request Path First: A 522 Does Not Mean the Entire Website Is Unreachable

A typical HTTPS website involves at least two connections: the client connects to the Cloudflare edge, and Cloudflare connects to the origin endpoint. If that endpoint sits in front of a cloud load balancer, reverse proxy, and application service, the latter part of the path needs to be broken down further.

The logical sequence for a normal request is: the client resolves the domain and connects to the edge; the edge checks the request and cache status; when an origin fetch is needed, the edge connects to the configured destination address and port; if the origin connection uses HTTPS, a TLS handshake follows; the edge then sends the HTTP request, and the endpoint or application returns a response. Existing connections may be reused, so not every origin request involves a new TCP handshake.

This article investigates common edge-to-origin connection or acknowledgment timeout scenarios. It treats “the TCP connection could not be established” and “the connection was established, but the origin did not promptly acknowledge receipt of request data” as two hypotheses to verify, rather than identifying the precise trigger stage from the error page alone. Acknowledgment here means a TCP ACK, not that the application has finished processing or returned an HTTP response. One completed handshake does not prove that the rest of the connection is healthy. Do not search only for SYN packets, and do not attribute every long wait to slow application processing.

The wait before the browser displays an error may also be affected by connection reuse, intermediate layers, and retries. You cannot identify the exact timeout stage from elapsed time alone; correlate it with endpoint connection logs and packet captures.

Observation

What it supports

What it still does not prove

A response with status 522 is received

This request received an HTTP-layer error response

All client-to-edge connections are healthy

A particular static resource is served successfully from cache

That resource can be delivered from cache

Origin connectivity is healthy or other resources are available

A direct connection to a specified endpoint succeeds

That particular request succeeded from the test location to the endpoint

Cloudflare's origin connection path is working

Application access logs are empty

No recorded request was found in the current logs

No packets reached the endpoint

A SYN is captured at the endpoint, but no outgoing SYN-ACK is seen

Endpoint processing, filtering, or the return-packet path deserves priority investigation

Application business logic is the root cause

If the actual response is a different error, investigate according to that status rather than carrying over every assumption just because a user reported “522.” For issues already showing abnormal proxy upstream responses, see layered 502 troubleshooting, where the focus shifts to upstream connections, responses, and proxy logs.

Capture One Failed Request Before Investigating Regional or Intermittent Patterns

Save the Minimum Information Needed to Correlate Both Sides

Record at least the failure time and time zone, domain and path, HTTP method, status code, duration, client network, and the CF-Ray value in the response, if present. Also record any recent changes to DNS, origin addresses, ports, load balancing, certificates, or origin firewalls.

Request identifiers are useful for correlating support tickets and logs, but they are not evidence of a network path. An identifier alone cannot show which packets reached the origin, nor can it replace an endpoint packet capture. If you want application logs to record this identifier, configure that before an incident. If a connection never reaches HTTP processing, no such record will be created.

Do not post complete Cookies, authentication headers, access tokens in query strings, or real origin addresses in public tickets. Use redacted information for public collaboration, and provide details through controlled support channels only to the extent necessary.

Use the Same Request Type to Observe the Edge Response

The following command is intended for an authorized test environment. Replace the example domain and path with your own target. It uses GET rather than HEAD to avoid differences in processing logic. The initial test neither follows redirects nor retries automatically, so it does not mask the first failure.

curl --noproxy '*' --http1.1 -sS \
  --connect-timeout 10 --max-time 60 \
  -D edge-headers.txt -o /dev/null \
  -w 'code=%{http_code} remote=%{remote_ip} dns=%{time_namelookup} tcp=%{time_connect} tls=%{time_appconnect} first=%{time_starttransfer} total=%{time_total}\n' \
  'https://www.example.com/healthz'

/healthz is only an example. First confirm that it exists, whether it requires authentication, and whether it can be cached. A successful health check does not mean that order or login requests will succeed. You still need safe, read-only validation of the affected business path.

The 10-second and 60-second values are local diagnostic limits, not Cloudflare timeout settings. If the test ends at 60 seconds first, record it only as a client-side timeout; you cannot claim to have observed a 522. Extend the total time limit under controlled conditions if necessary.

According to the official curl manual, these timings are primarily cumulative milestones measured from the start of the request: time_connect is not the duration of the TCP stage alone, and time_appconnect is not the TLS duration alone. For a single, newly established HTTPS connection without redirects, subtracting the name-resolution completion time from the TCP completion time gives an approximate view of TCP connection establishment. Subtracting the TCP completion time from the TLS completion time gives an approximate view of the TLS stage.

The key limitation is this: When testing through a proxied domain, these TCP and TLS timings primarily describe the test-machine-to-edge connection, not the edge-to-origin connection. A high time_starttransfer can include edge processing, waiting for the origin, and other factors; it cannot all be labeled application execution time. When a 522 is returned, curl may still complete the transfer normally because it successfully received an HTTP error response.

Verify the Actual Origin Target, Not Just Public DNS Results

The addresses returned publicly for a proxied domain generally serve client access. Do not treat them as the origin addresses Cloudflare is currently connecting to. Check the following against your account configuration and infrastructure records:

  • Whether the domain is currently proxied, and what the actual origin target is.

  • Whether any rules change the destination host, port, Host header, or TLS server name.

  • Whether there are multiple endpoints, load-balancing pools, failover, or intermediate cache layers.

  • Whether the origin connection actually uses HTTP or HTTPS, and whether the destination port has the appropriate listener.

  • Whether a recent migration left old addresses in place, and whether both IPv4 and IPv6 endpoints are maintained correctly.

A browser connecting to the edge over IPv6 does not mean the edge connects to the origin over IPv6. Likewise, a client receiving a response over IPv4 does not prove that the origin connection uses IPv4. Assess the two connections separately. A public DNS lookup cannot replace a review of the origin configuration in the account.

If failures occur only on certain networks or at certain times, consider both “different endpoints” and “different paths” as hypotheses. Do not infer the complete origin route solely from the edge IP, ASN, or geographic location visible to the client. To help organize domain-related observations, you can use CdnChart's website speed test to inspect public-facing endpoint behavior. However, these external observations cannot read account configuration or replace origin-side evidence.

Test the Origin Directly While Preserving Host, SNI, and Security Boundaries

Use --resolve to Change Only the Connection Address

Requesting an origin IP directly and adding a Host header is not a reliable HTTPS comparison. The TLS handshake occurs before HTTP headers are sent, so server-name selection and certificate validation may already differ. A better approach is to retain the original URL and specify the connection address with --resolve.

curl --noproxy '*' --http1.1 -sS \
  --resolve 'www.example.com:443:203.0.113.10' \
  --connect-timeout 10 --max-time 60 \
  -D origin-headers.txt -o /dev/null \
  -w 'code=%{http_code} remote=%{remote_ip} tcp=%{time_connect} tls=%{time_appconnect} first=%{time_starttransfer} total=%{time_total}\n' \
  'https://www.example.com/healthz'

203.0.113.10 is a documentation example address and cannot be used for actual validation. This command preserves the URL hostname for Host, TLS SNI, and certificate validation, changing only the connection address associated with the specified host and port.

It assumes that the actual origin connection also uses this domain's HTTPS endpoint on port 443. If the account configures a different Host, SNI, or destination port, reproduce that configuration in the test rather than treating the default example as the production path. Do not add -k to skip certificate validation by default, as doing so hides certificate problems.

Four Results and Four Follow-up Paths

The direct connection also times out: Prioritize the destination address, port, access permissions for the test source, listener, and network. The issue is no longer limited to Cloudflare's origin connection, but the test machine may be outside the origin's allowed source range, so you still cannot conclude that the origin is offline.

The direct connection is immediately refused: Check for a missing listener, an incorrect port, or an active rejection at some layer. An immediate refusal differs from silently dropping traffic until it times out, but one refusal does not mean every origin request will necessarily receive the same error.

TCP succeeds, but TLS fails: Check the certificate chain, SNI, TLS configuration, and client certificate requirements. This shows that the direct test at least completed TCP connection establishment. Continue investigating by protocol layer rather than recording a certificate validation failure directly as the root cause of a 522.

Direct connections succeed consistently, but the proxied endpoint still returns 522: Prioritize differences in source-address policies, network paths, actual origin targets, and load. This makes a difference in the Cloudflare-to-endpoint segment more likely, but it is not sufficient to conclude that Cloudflare's network is faulty.

If the origin allows only trusted proxy sources, do not open it to the entire internet for a direct test. Temporarily allow only an authorized test machine's address to access the specified port, set an expiry, and revoke access when testing is complete. For long-term access restrictions, see origin hiding and access control: hiding an address is not a complete access-control measure, and troubleshooting should not undermine existing boundaries.

Capture Packets at the Endpoint: Distinguish “Never Arrived” from “Arrived but No Reply”

When public-facing tests cannot locate the problem, observe TCP at the actual origin endpoint. That endpoint may be a load balancer rather than an application virtual machine. If traffic is dropped at a cloud gateway first, seeing no packets on the application machine is expected.

The following command is for an authorized Linux endpoint and uses port 443 as an example to inspect TCP summaries briefly. Before running it, confirm both the origin port configured in the account and the port that actually receives connections at the capture location. If the actual port is not 443, replace the port number in the filter. If port mapping exists along the path, use the mapped port that reaches this endpoint. Do not treat empty output from capturing the wrong port as evidence that the connection never arrived. Run the capture during a known reproduction window and stop it promptly. In high-traffic environments, further restrict the capture to verified source addresses to avoid unbounded collection.

sudo tcpdump -ni any -nn -tttt -s 96 -c 200 'tcp port 443'

To observe multiple endpoint ports, run separate captures with the relevant port substituted. Record the capture location, filter port, and reproduction time for each to avoid confusing results from different paths.

This is not a complete production traffic capture procedure. The output still contains network metadata and must be stored under controlled access. Do not disclose real origin addresses publicly. -s 96 limits the amount captured per packet, but it does not guarantee that no sensitive content is included. If you need to write a capture file, separately define permissions, retention periods, and redaction methods.

Branch One: No Matching Connection Reaches the Endpoint

First confirm that you are capturing at the correct endpoint, on the correct interface and port, with aligned timestamps. Then work backward through cloud security groups, network ACLs, upstream firewalls, load-balancer connection logs, and the actual origin address.

The most valuable question at this point is: “At which observable boundary does the connection attempt stop?” rather than “Why did the application not write a log?” If the configuration still points to an old endpoint, adjusting application threads will not help.

Branch Two: Repeated SYN Packets Arrive, but No Normal Reply Is Seen

Check the local firewall, listener, kernel connection state, and resource limits. Also verify whether replies leave through another interface and whether asymmetric routing is involved. Not seeing a SYN-ACK on one interface does not immediately prove that the host sent none at all.

If SYN-ACK packets leave but the peer continues retransmitting SYN packets, prioritize the return path, upstream stateful devices, or lost return packets. Correlate with logs from the other side or intermediate layers rather than treating a capture at one point as a complete view of both directions.

Branch Three: The Handshake Completes, but a Timeout Still Occurs Later

Continue inspecting data packets, ACKs, retransmissions, and window behavior. If transmitted data is repeatedly retransmitted and acknowledgments do not advance, investigate potential causes such as packet loss, connection tracking, receiver processing, and path MTU. Validate MTU further only when evidence is consistent with packet size, fragmentation, or related control messages. Do not start by changing MTU globally.

If TCP data acknowledgments are normal and the request has reached the HTTP layer, but the service simply takes a long time to return an application result, recheck the error code, proxy logs, and timestamp correlation. Slow application execution and a connection timeout are not the same fact. Do not treat them as interchangeable just because both involve a long wait.

Check Listeners, Queues, and Firewalls: Do Not Substitute Restarts for Diagnosis

First Determine Whether the Endpoint Can Keep Accepting Connections

On a Linux endpoint, correlate listener status, connection summaries, and kernel counters with the reproduction window. The following listener query uses 443 as an example. If the actual origin port differs, replace 443 in the query with the port that actually receives connections at this endpoint before deciding that a listener is missing:

sudo ss -lntp '( sport = :443 )'
ss -s
nstat -az | grep -E 'ListenOverflows|ListenDrops|TCPSynRetrans'

The listener output confirms whether the destination port and process exist. Queue fields for listening sockets help assess queue pressure; interpret their specific meaning according to the system version. Summary information shows the scale of connections. For kernel counters, compare increases across the failure window rather than treating nonzero historical totals as evidence of a current problem.

If no listener exists, first restore the correct service or destination port. If queue drops increase along with the failures, investigate the process's ability to accept connections, file descriptors, CPU, memory pressure, and downstream blocking. Simply increasing the backlog changes queuing conditions; it does not automatically increase application throughput and may prolong the wait before failure.

A restart can sometimes temporarily clear connections or free resources, but it also destroys important evidence. Unless restoring service requires an immediate restart, first preserve a short window of queue, resource, and log evidence. After restarting, continue investigating why resources become exhausted again.

Check Restrictions on Proxy Sources, Not Just the Edge WAF

The network connection source seen by the origin may be a proxy egress address, not the end user's address. If connection-layer limits on concurrency or new connections per source are too low, legitimate user traffic can be affected when it is aggregated at the endpoint.

Check cloud security groups, network ACLs, host firewalls, automated banning tools, load-balancer connection policies, and connection-tracking capacity in turn. First export the rules actually in effect, then use drop logs from the failure window to examine source addresses, destination ports, matched rules, and actions. The edge IP resolved by a browser is not a substitute for the origin-facing source ranges, and a source address seen in one packet capture is not a permanent allowlist.

If evidence points to incorrectly blocked source addresses, first use account configuration and vendor support channels to confirm the origin-facing egress addresses actually used by that account and the corresponding officially maintained ranges. Cloudflare's cache documentation lists dedicated CDN egress IP capabilities, so do not assume that one generic source list applies to every account. For the confirmed applicable ranges, check both relevant IPv4 and IPv6 networks and their update dates. Do not treat historical tickets, old rules, or addresses copied statically into an article as a permanent list. Until you have verifiable ranges, do not permanently broaden access; preserve the drop evidence and coordinate confirmation first.

Use the smallest change needed for security validation: adjust only the relevant endpoint, port, and confirmed source ranges, and record the previous rules, review time, and rollback method. Do not disable the firewall or WAF globally. HTTP security rules at the Cloudflare edge and TCP filtering at the origin endpoint are separate control points. An allow action at the former cannot fix silent packet drops at the latter.

Why Images Work While Pages Fail: Caching Changes How Failures Appear

Cloudflare's cache can deliver existing copies directly, reducing origin requests. Its cache documentation also explains how caching reduces origin load and how purging causes content to be fetched again. Therefore, “images work, but pages return 522” may simply mean that the images did not require an origin fetch while pages or APIs did. There is no contradiction.

During troubleshooting, group cacheable static resources, anonymous pages, login requests, and dynamic APIs separately. Cache-status information in a response can help explain an individual request, but a single hit or miss signal cannot reconstruct the complete internal path. An edge cache miss also does not necessarily mean the request went directly to the organization's origin; intermediate caches or other proxy layers may still exist.

Do not generate large numbers of cold requests using random query parameters or a full cache purge to “confirm the problem.” Query parameters may not be part of the current cache key, making the test both uncontrolled and ineffective. A full purge may send traffic previously served from cache to the origin at the same time, amplifying connection pressure.

A safer approach is to use a diagnostic path confirmed to be uncacheable, inexpensive to access, and free of side effects, reproducing the issue at a low rate while observing the endpoint. If cache bypass, TTL, or purge behavior changed recently, compare origin request volume, concurrent connections, and error counts before and after the change. Keep request hit ratio and byte hit ratio separate: cache hits for a few large files can save substantial bandwidth without necessarily reducing connection pressure from small dynamic requests.

Choose Fixes Based on Evidence, Not the Error Page

Evidence obtained

Priority action

Action to avoid

Origin configuration points to an old address or incorrect port

Correct the target and validate every endpoint

Repeatedly changing application timeouts

Clear drop records exist before the endpoint

Correct the network rules within the smallest necessary scope

Disabling security protections across the board

Listener queue drops increase along with errors

Resolve the acceptance bottleneck, capacity issue, or downstream blocking

Only increasing queue lengths and timeouts

One endpoint is faulty and a backup endpoint has passed validation

Switch traffic gradually and retain a rollback option

Changing all DNS traffic without validation

Direct connections succeed, but origin packets do not arrive, and the target configuration is verified

Collect timestamps and endpoint evidence, then coordinate with network operators and vendor support

Declaring the network healthy solely because Ping works

If you suspect a capacity issue, first verify where connection pressure comes from, then decide whether to expand endpoint capacity, reduce unnecessary origin requests, reuse connections, or optimize the application. Correct caching can reduce static-resource load, but login, payment, and personalized content must not be cached unsafely just to reduce error rates.

Before switching origin endpoints, validate the backup path's listener, certificate, Host/SNI, content consistency, and access controls. Switching only the internal origin target has different effects from changing public DNS. The latter also involves TTL, recursive caches, and existing client connections; it will not move every user to the new path immediately after the change.

Do not treat a plan upgrade or CDN replacement as an unverified fix. If the root cause is origin queue exhaustion, the same problem may recur through another proxy. Only when the root cause is a particular origin connection path that persistently fails to meet business requirements should you evaluate alternatives under the same resource, time-window, request-header, and cache conditions, retaining timeout and failure samples as well.

Validate Recovery: One Successful Request Does Not Mean the Incident Is Over

After recovery, cover the original failure conditions rather than opening the home page once. Retain at least the following checks:

  • The originally affected path works, with no inappropriate relaxation of authentication, redirects, status codes, or content handling.

  • Requests requiring origin access and requests served from cache both work correctly.

  • Every endpoint actually in use has been checked, with the relevant paths validated separately where dual-stack connectivity is involved.

  • Endpoint queues, drops, retransmissions, and resource pressure show no continued abnormal growth during the observation window.

  • Temporary test permissions have been revoked, with no residual weakening of security rules or certificate validation.

  • If traffic was switched gradually, rollback triggers have been defined for error counts, connection pressure, or business transaction failures.

When compiling results, retain each request's success or failure, error type, duration, and observation location. Do not remove timeout samples and compare only successful requests. Regional P95 values also cannot simply be averaged into an overall P95; aggregate the raw samples or report the regions separately. External probe results and contractual SLAs use different measurement criteria. CdnChart's measurement methodology can help define the boundaries of the evidence.

The final outcome should be a verifiable root-cause statement: which endpoint and which connection segment failed to establish or make further progress, under what conditions, and which change eliminated the corresponding anomaly. Only when you can answer those questions is Cloudflare 522 troubleshooting truly complete. Otherwise, the disappearance of the error page may simply mean that caching, traffic changes, or a brief recovery has temporarily hidden the problem.

  • Cloudflare
  • Cloudflare 522 troubleshooting
  • Edge-to-origin connection timeout
  • TCP packet capture and origin connectivity validation

Related posts