Skip to content

What is a cf-ray header? Reading a Cloudflare Ray ID

A cf-ray header is the unique ID Cloudflare gives every proxied request, plus the data centre that served it. Read one and find it in your logs.

A cf-ray is the unique identifier Cloudflare attaches to every request it proxies, returned to you as a response header that looks like cf-ray: 95f2a1b3c4d5e6f7-YUL. It has two parts joined by a hyphen: a 16-character hexadecimal request ID that belongs to that one request and nothing else, and a three-letter IATA airport code naming the Cloudflare datacenter — the colo — that handled it (YUL is Montréal, YYZ Toronto, EWR Newark). Cloudflare also prints it at the bottom of its own error and challenge pages and forwards it to your origin server in a CF-RAY request header, which is why support asks for it on every case: it is the one string that identifies a single request across the edge, your own logs, and a vendor ticket. Its usefulness expires with the logs it points into — days on most plans, not months — so it is only worth what you capture while the problem is still happening.

What you’ll accomplish

  • Read any cf-ray value and say what each half means without looking anything up.
  • Capture the small set of headers that decide whether a problem is edge-side, cache-side, or origin-side, in one command.
  • Prove a hostname is actually proxied before you spend an hour tuning dashboard settings that never touch its traffic.
  • Log the Ray ID at your origin so an edge event and an origin access-log line can be joined exactly.
  • Hand a support ticket — internal or vendor — a Ray ID that someone else can act on.

Prerequisites

  • A hostname proxied through Cloudflare. An orange-cloud DNS record. A grey-cloud (DNS-only) record produces no cf-ray at all, which is itself a useful result.
  • curl on a machine that can reproduce the problem. Any recent build. On Windows, curl.exe ships with the OS; PowerShell’s Invoke-WebRequest works too but formats headers differently.
  • Dashboard access for the correlation steps, and an honest note about plan tiers: Security Events is available on every plan and lets you search by Ray ID, but its retention window is much shorter on Free than on paid plans. Instant Logs starts at Business. Logpush and Logpull are Enterprise features. If your zone does not have a log surface that keeps requests long enough, origin logs are your fallback — see what Cloudflare logging gives you on Free, Pro, and Business.
  • Write access to your origin’s log format, for the step that makes rays greppable in your own access logs. Change it before the incident, not during.

How it works

Every request that reaches a Cloudflare datacenter gets an identifier minted there, before any routing or cache decision is made. That identifier travels with the request for the rest of its life: it goes into Cloudflare’s own request log, into the CF-RAY header sent to your origin if the request goes that far, into the cf-ray response header sent back to the client, and onto the visible error page if the edge answers with a 5xx or a challenge.

cf-ray value split into hexadecimal request ID and colo code along the request path

The two halves answer different questions. The hex half answers which request, and it is what you grep for. The colo half answers where, and it matters more than people expect: Cloudflare routes by network rather than by geography, so two people in the same city on different ISPs can land on different colos, and one of them can be having a bad day while the other is fine. A Montréal user whose ray reads -CDG is worth a second look when you are chasing latency.

Two more headers ride along in the same response and change what the ray means. server: cloudflare is your proof the response came through the proxy at all. cf-cache-status is the edge’s verdict on caching, and it decides whether the next thing you inspect is a cache rule or your application — the full value-by-value breakdown lives in decoding cf-cache-status.

Step-by-step

  1. Capture the headers with a single request. Use -sSI rather than -I alone: -s silences the progress meter, -S still shows real errors, and -I sends a HEAD request so you get headers without the body.

    curl -sSI https://example.com/

    A healthy proxied response looks like this. The Ray ID below is an illustrative example, not a real one:

    HTTP/2 200
    date: Wed, 03 Sep 2026 14:22:08 GMT
    content-type: text/html; charset=UTF-8
    vary: Accept-Encoding
    cache-control: max-age=0, must-revalidate
    cf-cache-status: DYNAMIC
    server: cloudflare
    cf-ray: 95f2a1b3c4d5e6f7-YUL
    alt-svc: h3=":443"; ma=86400
  2. Confirm the request was proxied at all. This is the first thing to check and the one most often skipped. Strip out the noise and read four lines:

    curl -sSI https://example.com/ | tr -d '\r' | grep -iE '^(server|cf-ray|cf-cache-status|cf-mitigated):'
    cf-cache-status: DYNAMIC
    server: cloudflare
    cf-ray: 95f2a1b3c4d5e6f7-YUL

    If server reads nginx, Apache, or LiteSpeed and there is no cf-ray, that hostname is not going through Cloudflare. Every setting in the dashboard is irrelevant to this traffic until that changes.

  3. Split the ray into its two halves. Worth doing once by hand so the shape sticks:

    curl -sSI https://example.com/ | tr -d '\r' | awk 'tolower($1)=="cf-ray:" {split($2,a,"-"); printf "request id: %s\ncolo:       %s\n", a[1], a[2]}'
    request id: 95f2a1b3c4d5e6f7
    colo:       YUL
  4. Decode the colo code without guessing. Cloudflare exposes a plain-text diagnostic endpoint on every proxied hostname that reports the colo directly, alongside the client IP the edge sees and the negotiated protocol:

    curl -s https://example.com/cdn-cgi/trace
    fl=123f45
    h=example.com
    ip=203.0.113.24
    ts=1788452528.771
    visit_scheme=https
    colo=YUL
    sliver=none
    http=http/2
    loc=CA
    tls=TLSv1.3
    sni=plaintext
    warp=off
    gateway=off

    colo=YUL should match the suffix on your cf-ray. loc=CA is the country the edge attributes to the client, and ip= is the address your origin will see in CF-Connecting-IP.

  5. Read cf-cache-status for what it actually says. HIT means the edge answered from cache and your origin was never consulted. MISS means it went to the origin and stored the result. EXPIRED means it was cached, the TTL ran out, and it was refetched. REVALIDATED means a stale copy was confirmed fresh. BYPASS means the object was cacheable but a rule, cookie, or origin header said not to. DYNAMIC means it was never eligible in the first place — the default for HTML — and is not an error. Pair it with age when someone reports stale content:

    curl -sSI https://example.com/assets/logo.png | tr -d '\r' | grep -iE '^(cf-cache-status|age|cf-ray):'
    cf-cache-status: HIT
    age: 4127
    cf-ray: 95f2a1b3c4d5e701-YUL

    A HIT with a four-figure age on a page someone just updated is a purge or TTL conversation, not an application bug.

  6. Check alt-svc if HTTP/3 is in question. The edge advertises it in the response; whether your client uses it is a separate matter:

    curl -sSI https://example.com/ | tr -d '\r' | grep -i '^alt-svc:'
    alt-svc: h3=":443"; ma=86400

    To confirm the advertisement is honoured, force it — this needs a curl built with HTTP/3 support, which many distribution packages are not:

    curl --http3 -sSI https://example.com/ | head -1
    HTTP/3 200
  7. Make the ray greppable at your origin. Cloudflare sends the request ID to your origin in the CF-RAY request header. In Nginx, add it to your log_format:

    # nginx.conf - record the edge request ID and the real client IP
    log_format cfray '$remote_addr - $remote_user [$time_local] "$request" '
                     '$status $body_bytes_sent "$http_referer" "$http_user_agent" '
                     'cf_ray=$http_cf_ray cf_ip=$http_cf_connecting_ip';

    In Apache, the equivalent token in LogFormat is %{CF-RAY}i. Reload, then a ray from a ticket becomes a log line:

    grep 95f2a1b3c4d5e6f7 /var/log/nginx/access.log
    172.71.124.9 - - [03/Sep/2026:14:22:08 +0000] "GET / HTTP/1.1" 200 18422 "-" "curl/8.7.1" cf_ray=95f2a1b3c4d5e6f7 cf_ip=203.0.113.24

    Grep the hex half only. The colo suffix is not reliably present in what the origin receives, and searching for the full string will find nothing.

  8. Correlate the ray on Cloudflare’s side. In the dashboard, Security Events accepts a Ray ID as a filter and will show you the rule that acted on that request, if any. If the zone has Logpush, the HTTP requests dataset carries the same value in the RayID field, so once the logs land in a query engine the lookup is direct:

    SELECT RayID, ClientIP, EdgeStartTimestamp, EdgeResponseStatus, CacheCacheStatus
    FROM http_requests
    WHERE RayID = '95f2a1b3c4d5e6f7';

    A ray present in Cloudflare’s logs but absent from your origin logs means the edge answered it — cache, redirect, challenge, or block — and never asked you.

Validate it works

Prove you captured the right ray for the right request rather than a leftover from a previous one. Every request gets its own ray, so two consecutive calls must differ:

for i in 1 2; do curl -sSI https://example.com/assets/logo.png | tr -d '\r' | grep -iE '^(cf-cache-status|age|cf-ray):'; echo '--'; done
cf-cache-status: MISS
cf-ray: 95f2a1b3c4d5e6f7-YUL
--
cf-cache-status: HIT
age: 3
cf-ray: 95f2a1b3c4d5e701-YUL
--

Two different rays, and MISS turning into HIT on the second call, is the cache behaving normally. Now force a fresh miss so you know you are reading the origin path and not a cached answer from an hour ago. A unique query string produces a different cache key:

curl -sSI "https://example.com/assets/logo.png?cb=$(date +%s)" | tr -d '\r' | grep -iE '^(cf-cache-status|cf-ray):'
cf-cache-status: MISS
cf-ray: 95f2a1b3c4d5e7a2-YUL

Finally, close the loop: take that exact hex string and find it in your origin access log. If it is there, the request traversed the edge and reached your server, and both timestamps refer to the same event.

Troubleshooting

Decision tree from a user report to the Cloudflare header that answers it

  • No cf-ray in the response at all. The record is DNS-only, or the client resolved the origin IP directly through a hosts-file entry or split-horizon DNS. Check the proxy status of that specific record — proxying is per record, not per zone, so www can be proxied while api is not.

  • The ray returns nothing in the dashboard. Log retention is finite and short. On Free zones, Security Events keeps a small window; a ray from last week is simply gone. Capture the header set into the ticket at report time rather than expecting to look it up later, and treat your own origin logs as the longer-lived record.

  • cf-cache-status: DYNAMIC read as a fault. It means “not eligible for caching,” which is the correct and expected value for HTML on a default configuration. Nothing is broken. If you want HTML cached, that is a Cache Rule, not a bug report.

  • The ray came from the wrong hop. curl -sSI shows only the first response. If the URL redirects, the ray you captured belongs to the 301, not to the page that failed. Add -L deliberately and read every hop, or request the final URL directly:

    curl -sSIL https://example.com/old-page | tr -d '\r' | grep -iE '^(HTTP/|location|cf-ray):'
    HTTP/2 301
    location: https://example.com/new-page
    cf-ray: 95f2a1b3c4d5e83b-YUL
    HTTP/2 200
    cf-ray: 95f2a1b3c4d5e84c-YUL
  • Every asset on the page has a different ray, so the ticket is unreproducible. That is expected — one ray per request means a page with forty assets generates forty rays. Ask for the ray of the failing request specifically: the one on Cloudflare’s error page, or the one on the single request that returned a bad status in the browser’s network panel. A ray for the HTML document does not describe a font that failed to load.

When this is the wrong approach

Reading headers diagnoses; it does not repair, and the ray is silent about several things people ask it to explain.

It cannot see inside your application. A 200 with a cf-ray tells you Cloudflare relayed a response; it says nothing about whether that response contained a stack trace, an empty cart, or the wrong tenant’s data. Origin-side application errors need origin-side logs and traces.

It cannot describe anything that happened before the TLS handshake completed. A client that failed DNS resolution, could not reach the edge, or aborted during the handshake never received a response, so there is no cf-ray to read and no visible record on the client side at all. Connection-level failures are a different investigation.

And a cached HIT is not a health check. Cached assets keep serving while an origin is unreachable, so a homepage that looks fine can sit in front of a dead backend. Use an uncacheable path or a direct origin request when you want to know whether your server is actually answering.

The header reference for anything not covered here lives in the Cloudflare fundamentals documentation, and the log field names in the Cloudflare logs documentation.

If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.