Edge or origin
A Cloudflare block page, a WAF challenge and your API's JSON error are three different responses. Check the body and the headers before you change a rule.
A 429 is the edge telling a client to slow down. If the bucket is keyed on IP, one office NAT, one mobile carrier or one CI runner can take the block for everyone behind it, while a distributed client stays under every per-data-center counter.
This page is free. It covers how to read a 429, why the same rule can block a whole office and miss an attack, and the response contract that stops retries from turning a rate limit into an outage.
A Cloudflare block page, a WAF challenge and your API's JSON error are three different responses. Check the body and the headers before you change a rule.
IP, IP with NAT support, account, API key, path, or a custom expression. The key decides who shares a bucket; the number only decides when it empties.
Cloudflare keeps counters per data center, not globally. A client spread across regions can stay under each local limit while the origin sees the sum.
Counters update after a short delay, so excess requests can still reach the origin. A rate limit is burst control, not a hard quota.
| Command or view | What it tells you |
|---|---|
| curl -sS -D - -o /dev/null https://app.internal/api/items | Status, cf-ray, retry-after, and whether the response is yours or the edge's. |
| for i in $(seq 1 30); do curl -s -o /dev/null -w '%{http_code} %{time_total} ' https://app.internal/api/items; done | Burst shape: when the first 429 appears, and whether it clears. |
| curl -s https://api.ipify.org from the affected network | How many users share that egress address. |
| curl -sS -D - https://app.internal/ | grep -i 'cf-cache-status|age' | Whether the error itself is cached and being replayed. |
| Security → Events in the dashboard | Which rule matched, the characteristic values, and the data center. |
| Worker logs: request.cf.colo, cf-connecting-ip | The counter scope and the key you think you are counting. |
| # | Failure mode | What you see | What to do |
|---|---|---|---|
| 1 | Per-IP counting behind NAT | Everyone in one office gets 429 at the same moment; the address has thousands of users. | Use IP with NAT support where available, or count on an authenticated key (session, API token) and keep a separate, higher per-IP burst limit. |
| 2 | Per-data-center counters | The attack continues while one region is blocked, or an office is blocked while the attacker spreads across regions. | Treat edge limits as burst control, add an origin-side global limit for the expensive path, and alert on origin load, not only on edge 429s. |
| 3 | The retry storm | 429s turn into 503s; every client retries at the same second. | Return Retry-After, add exponential backoff with jitter, cap attempts, and make your own SDKs honour the header. |
| 4 | Counting the wrong requests | A normal page load of 40 assets trips a rule meant for the login endpoint. | Scope by path and method, exclude static assets and health checks, and count the request that costs you something. |
| 5 | Monitors and health checks eat the budget | Synthetic checks from one IP are blocked at the same time every day; the status page says the site is down. | Allowlist monitor egress or give it a separate authenticated path and a distinct budget. |
| 6 | A 429 with no contract | Clients show a generic error, users retry by hand, and support tickets say the site is broken. | Return a JSON body with a machine-readable code and Retry-After; document it and make the retry advice match the bucket. |
| Decision | Question to answer |
|---|---|
| Key | Who should share a budget: one IP, one account, one API key, one path? Pick the unit that matches the abuse. |
| Threshold | What is the measured p99 for a legitimate client in the window? Start above it, not at a round number. |
| Window | A short window blocks bursts; a long one locks people out after a brief spike. |
| Action | Block, managed challenge, or log only. For browsers, a challenge is often better than a hard 429; for APIs, a clear 429 is better than a challenge. |
| Scope | Edge only, origin only, or both. Edge limits are per data center; origin limits are global but cost you capacity. |
| Part | Example | Why |
|---|---|---|
| Status | 429 | RFC 6585 defines 429 for too many requests; do not reuse 403 for rate limiting. |
| Retry hint | Retry-After: 30 | RFC 9110 defines the header. Without it, every client guesses and they all guess zero. |
| Body | {"error":"rate_limited","retry_after":30} | A machine-readable code lets clients back off instead of showing a generic failure. |
| Cache | Cache-Control: no-store | An error cached at the edge is an outage that outlives the traffic spike. |
Send a burst, confirm the first 429, wait for Retry-After, and confirm the next request succeeds rather than staying blocked.
Run the same burst from a second host behind the same NAT. If both are blocked while normal users are not, the key is wrong.
Request the same URL twice after the burst and check cf-cache-status. A HIT on a 429 means the edge is replaying the failure.
Confirm the synthetic check passes during the burst, or that it is excluded from the rule on purpose.
They share one public address, so a per-IP rule treats them as one client. Use a NAT-aware characteristic or key the rule on an authenticated identity.
Cloudflare does not share rate-limit counters across the whole network; each data center counts on its own. Add an origin-side limit for the expensive path.
503 means the server cannot handle the request; 429 means the client sent too many. Use 429 with Retry-After for rate limiting, and reserve 503 for real overload.
For browsers, often yes: it distinguishes a human from a script without a hard failure. For API clients, a 429 with a retry hint is clearer.
The paid runbooks cover the surrounding failures: cache rules that hide a deploy, AI gateway rate limits, and production defaults that only bite on a real domain.
This page is free, no checkout. Paid runbooks are $9.99 each and covered by the 7-day refund policy at /runbooks/refund.