Skip to content
Intermittent Cloudflare 522s on two services; the requests never reach the app
cr-alonso
OP

5 hours ago

Hi.

We see rare, intermittent Cloudflare 522 errors (connection timed out) in front of two services in the same project. The requests never reach either app, so it looks like Cloudflare's connection to Railway's edge doesn't complete.

Setup: two services in EU West (europe-west4), one replica each, on custom domains proxied by Cloudflare:

  • Web (Next.js): thefitnessdb.com
  • API (.NET): api.thefitnessdb.com

Serverless is off on both services. There are no restarts or crashes in either service's logs around the times below.

What we see:

  • Cloudflare counted 8 requests answered 522 between 13 and 19 November: 5 on thefitnessdb.com and 3 on api.thefitnessdb.com.
  • Each one failed after about 19.8 s, which matches Cloudflare's timeout for an origin that doesn't complete the TCP handshake.
  • Our own checks, from Europe through Cloudflare's Zurich data center, hit it about 4 times in 700 requests. A retry seconds later answers normally in under half a second.
  • Three of the eight came from an unrelated internet scanner, so it isn't specific to one client network.

Recent occurrences (UTC):

  • 2026-11-19 19:14:44, thefitnessdb.com /de/signup
  • 2026-11-19 09:05:07 (failed at 09:05:27), thefitnessdb.com /en/for-developers, CF-RAY a5ce0d26deb9862a-ZRH
  • 2026-11-19 about 09:02, thefitnessdb.com /en/for-developers
  • 2026-11-18 about 23:58, thefitnessdb.com /es/legal and /en/signup

Could you check whether Railway's edge saw or dropped these connections, and whether there's anything we should change on our side? We can send Cloudflare Ray IDs for the others if that helps.

$20 Bounty

6 Replies

Railway
BOT

5 hours ago

This thread has been opened as a bounty so the community can help solve it.

Status changed to Open Railway • about 5 hours ago


galaxys22702

4 hours ago

This appears to be an intermittent connection issue between Cloudflare and Railway’s edge, not an application problem. The 19.8-second failures match Cloudflare’s TCP timeout.

Since both services are affected and retries succeed immediately, Railway should investigate its edge logs using the Cloudflare Ray IDs and UTC timestamps.

I’d recommend checking DNS and edge connectivity before changing application settings.


juniordias00

4 hours ago

Yes, the other Ray IDs would help. The most useful pair would be one failed request and the first successful, uncached retry to the same hostname and path. If the TCP handshake failed, Railway would never have received the HTTP CF-Ray header on that connection. Cloudflare can use the Ray ID to look up its side. For Railway, the UTC window and the source and destination IPs are more useful.

Your Nov 19 example gives a precise starting point: 09:05:07 to 09:05:27 UTC is 20 seconds at the precision shown, consistent with the 19.8 seconds you measured. Cloudflare documents a 19-second timeout waiting for a SYN+ACK and a separate 90-second timeout after TCP connects. All eight failures clustering around the shorter interval makes connection establishment the leading explanation. Empty application logs are expected in that case. They can’t show whether Railway received the SYN or whether a SYN+ACK was lost on its way back.

What I’d do with the evidence you already have:

  1. Pair the Cloudflare records. Start with a5ce0d26deb9862a-ZRH and its successful retry. Include the hostname, path, UTC start/end, Ray ID and Cloudflare colo for each. If your Cloudflare logs expose them, add EdgeServerIP (the Cloudflare server contacting the origin), OriginIP (the destination), EdgeResponseStatus and OriginResponseStatus. A 522 paired with origin status 0 tells you Cloudflare received no HTTP response. If those fields aren’t available on your plan, send the Ray IDs and times anyway. Include one API failure so both services are represented.
  2. Compare the failures with successful traffic. Check whether failures cluster on one origin IP or Cloudflare colo. Include the number of successful requests through each as a baseline: four failures through Zurich mean something different if nearly all 700 checks went through Zurich. For a retry that reached the app, include its Railway HTTP log entry, X-Railway-Request-Id and X-Railway-Edge if available. ZRH identifies a Cloudflare location; europe-west4 identifies your deployment region. The Railway ingress for a given request is a separate observation.
  3. Verify the two settings you control. In Cloudflare DNS, compare each hostname’s configured target with the custom-domain target Railway shows for that specific service. Check whether a matching Cloudflare Origin Rule overrides the destination hostname or port. If you find a mismatch, correct that record or rule and compare subsequent failures. If both targets match, I’d leave the proxy, replica counts and application timeouts unchanged while the network teams investigate.

The question I’d send Railway networking is: “For 2026-11-19 09:05:07–09:05:27 UTC, do you have ingress telemetry for this Cloudflare source IP and Railway destination IP? Can you tell whether a SYN arrived and whether your edge sent a SYN+ACK? Here is the successful retry for comparison.” Share the IP pair and project/service identifiers privately with support.

If Railway sees the SYN arrive without a SYN+ACK leaving, its networking team has a specific ingress event to investigate. If it sees the SYN+ACK leave, give that finding and the failed Ray ID to Cloudflare so it can investigate the return path. If Railway only has HTTP logs for that window, an empty result leaves the packet-level question open. That distinction is why I’d escalate this before changing either app.

Cloudflare 522 timeouts · Cloudflare HTTP log fields · Railway edge routing · Comparable Railway investigation

Prepared with AI assistance and checked against the linked sources. The timing above comes from your report. I don’t have access to either provider’s network telemetry.


juniordias00

Yes, the other Ray IDs would help. The most useful pair would be one failed request and the first successful, uncached retry to the same hostname and path. If the TCP handshake failed, Railway would never have received the HTTP CF-Ray header on that connection. Cloudflare can use the Ray ID to look up its side. For Railway, the UTC window and the source and destination IPs are more useful. Your Nov 19 example gives a precise starting point: 09:05:07 to 09:05:27 UTC is 20 seconds at the precision shown, consistent with the 19.8 seconds you measured. Cloudflare documents a 19-second timeout waiting for a SYN+ACK and a separate 90-second timeout after TCP connects. All eight failures clustering around the shorter interval makes connection establishment the leading explanation. Empty application logs are expected in that case. They can’t show whether Railway received the SYN or whether a SYN+ACK was lost on its way back. What I’d do with the evidence you already have: 1. Pair the Cloudflare records. Start with a5ce0d26deb9862a-ZRH and its successful retry. Include the hostname, path, UTC start/end, Ray ID and Cloudflare colo for each. If your Cloudflare logs expose them, add EdgeServerIP (the Cloudflare server contacting the origin), OriginIP (the destination), EdgeResponseStatus and OriginResponseStatus. A 522 paired with origin status 0 tells you Cloudflare received no HTTP response. If those fields aren’t available on your plan, send the Ray IDs and times anyway. Include one API failure so both services are represented. 2. Compare the failures with successful traffic. Check whether failures cluster on one origin IP or Cloudflare colo. Include the number of successful requests through each as a baseline: four failures through Zurich mean something different if nearly all 700 checks went through Zurich. For a retry that reached the app, include its Railway HTTP log entry, X-Railway-Request-Id and X-Railway-Edge if available. ZRH identifies a Cloudflare location; europe-west4 identifies your deployment region. The Railway ingress for a given request is a separate observation. 3. Verify the two settings you control. In Cloudflare DNS, compare each hostname’s configured target with the custom-domain target Railway shows for that specific service. Check whether a matching Cloudflare Origin Rule overrides the destination hostname or port. If you find a mismatch, correct that record or rule and compare subsequent failures. If both targets match, I’d leave the proxy, replica counts and application timeouts unchanged while the network teams investigate. The question I’d send Railway networking is: “For 2026-11-19 09:05:07–09:05:27 UTC, do you have ingress telemetry for this Cloudflare source IP and Railway destination IP? Can you tell whether a SYN arrived and whether your edge sent a SYN+ACK? Here is the successful retry for comparison.” Share the IP pair and project/service identifiers privately with support. If Railway sees the SYN arrive without a SYN+ACK leaving, its networking team has a specific ingress event to investigate. If it sees the SYN+ACK leave, give that finding and the failed Ray ID to Cloudflare so it can investigate the return path. If Railway only has HTTP logs for that window, an empty result leaves the packet-level question open. That distinction is why I’d escalate this before changing either app. Cloudflare 522 timeouts · Cloudflare HTTP log fields · Railway edge routing · Comparable Railway investigation Prepared with AI assistance and checked against the linked sources. The timing above comes from your report. I don’t have access to either provider’s network telemetry.

galaxys22702

4 hours ago

Thanks for the detailed breakdown I agree this points to a network handshake issue I would compare failed Ray IDs with successful retries and have Railway check the connection logs before changing anything


galaxys22702

Thanks for the detailed breakdown I agree this points to a network handshake issue I would compare failed Ray IDs with successful retries and have Railway check the connection logs before changing anything

juniordias00

4 hours ago

Thanks, @galaxys22702. I agree. The 19.8-second failures are consistent with a TCP handshake timeout, and I’d ask Railway to check its edge connection logs before changing either service. Cloudflare Support docs

One detail I’d add when pairing the Ray IDs is whether the successful retry opened a fresh connection to Railway. If it reused an existing connection, it shows the app could respond at that moment. A retry that completed a fresh handshake would give Railway a closer comparison.


cr-alonso
OP

4 hours ago

Thanks both. Checked the settings on our side: both hostnames that saw the 522s (thefitnessdb.com and api.thefitnessdb.com) are proxied CNAMEs to the targets Railway gave each service, both on port 8080; Railway shows "Cloudflare proxy detected" on each, and there are no Origin Rules. So we're leaving the proxy and both services unchanged. Our own checks all run through ZRH, so "4 in 700" is the rate there. We'll post the next failure paired with its successful retry (Ray IDs, times and Railway's response headers).


cr-alonso

Thanks both. Checked the settings on our side: both hostnames that saw the 522s (thefitnessdb.com and api.thefitnessdb.com) are proxied CNAMEs to the targets Railway gave each service, both on port 8080; Railway shows "Cloudflare proxy detected" on each, and there are no Origin Rules. So we're leaving the proxy and both services unchanged. Our own checks all run through ZRH, so "4 in 700" is the rate there. We'll post the next failure paired with its successful retry (Ray IDs, times and Railway's response headers).

juniordias00

3 hours ago

Thanks, @cr-alonso. I’d leave port 8080 and both CNAMEs as configured. On Railway, 8080 is the port its edge uses to reach your app. A wrong target port typically produces a Railway 502. Your repeated 19.8-second failures fit Cloudflare’s 19-second wait for a TCP handshake response when connecting to the origin. Railway target ports · Cloudflare 522

I checked the Zurich maintenance timeline against your timestamps. Cloudflare recorded maintenance from 00:00 to 04:00 UTC on Nov 19. Your Nov 18 event at approximately 23:58 was close to the start. The Nov 19 failures at 09:05 and 19:14 were both outside that window. Since all 700 of your own checks went through Zurich, those checks alone can’t tell us whether other locations were affected. Cloudflare’s Zurich maintenance record

Railway networking team: Could you check ingress telemetry for thefitnessdb.com, Nov 19, 09:05:07–09:05:27 UTC? The Cloudflare reference is a5ce0d26deb9862a-ZRH. If the connection timed out before HTTP, the Ray ID would only be visible on Cloudflare’s side. The most useful finding from Railway would be whether the incoming SYN reached an edge and whether that edge sent a SYN+ACK. If Cloudflare’s EdgeServerIP and OriginIP are available for that request, the owner can share the pair privately to narrow the lookup. Cloudflare log fields

For the next pair, you can add X-Railway-Debug: 1 to your existing monitor. Here’s a one-request capture for curl 7.84 or newer. Run it against the same URL for each attempt and keep the UTC start time with each line.

date -u '+%Y-%m-%dT%H:%M:%SZ'

curl -q -sS --retry 0 --max-time 110 -o /dev/null \

-H 'X-Railway-Debug: 1' \

-w 'http=%{http_code} total=%{time_total}s ray=%header{cf-ray} cache=%header{cf-cache-status} edge=%header{x-railway-edge} zone=%header{x-railway-upstream-zone} id=%header{x-railway-request-id}\n' \

'https://thefitnessdb.com/en/for-developers'

On the successful retry, a matching Railway HTTP log entry confirms that request reached Railway. A Cloudflare cache HIT would make it unsuitable for that comparison. If your Cloudflare logs also show a positive OriginTCPHandshakeDurationMs on the successful retry, that gives both teams a particularly useful pair: a timed-out attempt followed by a newly established origin connection to the same hostname and path. Railway debug headers · Cloudflare handshake timing

Prepared with AI assistance. The capture command was tested locally with simulated responses.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...