HTTP 429 means you sent too many requests. How Retry-After works, exponential backoff with jitter, retry rules, 429 vs 503, and a tested retry wrapper.
HTTP 429 Too Many Requests means the server is rejecting you because you sent too many requests in a given amount of time. The fix is to wait, and to wait at least as long as the Retry-After header says when it is present.[1][4] Retry with exponential backoff and jitter, cap the attempts, and retry only requests that are safe to repeat.[2][4] Below: Retry-After parsing, a tested JavaScript retry wrapper, a vendor header table, common mistakes, and how to send a good 429 yourself. For neighboring codes, use the HTTP status codes reference.
What HTTP 429 means
RFC 6585 added 429 in April 2012. It says the user has sent too many requests in a given amount of time ("rate limiting"). The response representation SHOULD include details explaining the condition and MAY include a Retry-After header saying how long to wait before making a new request.[1]
Four details in the RFC matter more than the headline:
- It does not define how the server identifies the user or counts requests. Limits can be per resource, across the whole server, or across a set of servers, keyed by credentials or a stateful cookie.[1]
- Retry-After is optional (MAY), so a 429 can arrive with no wait hint at all and clients need a fallback delay.[1]
- Responses with 429 MUST NOT be stored by a cache.[1]
- Servers are not required to use 429. Under attack, the RFC says it may be more appropriate to drop connections or take other steps, because answering every request with a 429 still consumes resources.[1]
A 429 tells you a limit exists, not what it is. Vendors fill that gap with their own headers and error bodies.
Retry-After: seconds or a date
RFC 9110 defines the field as Retry-After = HTTP-date / delay-seconds. A delay-seconds value is a non-negative decimal integer, in seconds. The RFC's two examples are Retry-After: Fri, 31 Dec 1999 23:59:59 GMT and Retry-After: 120, where the delay is 2 minutes.[2] RFC 6585's own 429 example sends Retry-After: 3600.[1]
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Retry-After: 30
Cache-Control: no-store
{"error":"rate_limited","retry_after_seconds":30}A client that parses only integers breaks the first time a server sends a date. Handle both, and treat anything unparseable as "no hint". OpenAI's reference retry code does the same: it tries a number first, then a date, then falls back to its own backoff.[4]
Retry-After is a floor
OpenAI's guide says to treat the value as a minimum: wait at least that long and add a small random delay so multiple clients do not retry at the same moment.[4] Anthropic's docs agree: wait that many seconds, because earlier retries might fail.[3] Your own backoff schedule decides the wait only when the server gave no hint. When it did, the final delay is the larger of the two.
Rate limiting algorithms, and what the sources support
Servers decide when to emit a 429 with some counting scheme. The RFC deliberately leaves that open.[1] What the vendor docs confirm:
| Behavior | Source says | What it means for your client |
|---|---|---|
| Token bucket | Anthropic's API uses the token bucket algorithm: capacity is continuously replenished up to the maximum, rather than reset at fixed intervals[3] | Waiting a few seconds recovers some capacity. There is no top-of-the-minute reset to aim for |
| Ramp limits | After a sharp usage increase, a 429 can occur even while under the per-minute limits[3][4] | Increase traffic gradually. OpenAI's rule of thumb: past 1 million input tokens per minute, grow by no more than 50% every 15 minutes[4] |
| Fixed hourly window | GitHub: 60 unauthenticated requests per hour per IP, 5,000 per hour for authenticated users, with x-ratelimit-reset giving the window reset in UTC epoch seconds[5] | Sleep until the reset time, not for a guessed interval |
GitHub says its secondary limits can change without notice.[5] Read the response headers instead of hard-coding a vendor's numbers.
Exponential backoff with jitter
Exponential backoff means waiting briefly after a failed request, then increasing the delay after each further failure until the request succeeds or hits a retry limit. Adding random jitter keeps clients that failed together from retrying together.[4] OpenAI's guide also warns that unsuccessful requests count toward your per-minute limit, so resending in a tight loop makes things worse.[4]
The wrapper below uses full jitter (a random delay between zero and an exponentially growing cap), honors Retry-After as a floor, and refuses to retry non-idempotent methods. The max-of-server-delay-and-jittered-backoff step follows the pattern in OpenAI's manual backoff example.[4]
const IDEMPOTENT = new Set(['GET', 'HEAD', 'OPTIONS', 'PUT', 'DELETE'])
// Retry-After is either delay-seconds or an HTTP-date (RFC 9110, section 10.2.3).
export function parseRetryAfter(value, now = Date.now()) {
if (value == null) return undefined
const v = value.trim()
if (/^\d+$/.test(v)) return Number(v) * 1000
const at = Date.parse(v)
if (Number.isNaN(at)) return undefined
return Math.max(0, at - now)
}
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
export async function fetchWithRetry(url, init = {}, opts = {}) {
const {
maxAttempts = 5,
baseMs = 500,
capMs = 30_000,
maxWaitMs = 60_000, // give up if the server asks for longer than this
retryUnsafe = false, // set true only if the request carries an idempotency key
} = opts
const method = (init.method ?? 'GET').toUpperCase()
const canRetry = retryUnsafe || IDEMPOTENT.has(method)
for (let attempt = 0; ; attempt++) {
const res = await fetch(url, init)
if (res.status !== 429 || !canRetry || attempt + 1 >= maxAttempts) return res
const serverMs = parseRetryAfter(res.headers.get('retry-after'))
if (serverMs !== undefined && serverMs > maxWaitMs) return res // defer, do not hammer
// Full jitter: random value between 0 and min(cap, base * 2^attempt)
const backoffMs = Math.random() * Math.min(capMs, baseMs * 2 ** attempt)
// Retry-After is a floor, never something your own backoff may undercut
const waitMs = Math.max(serverMs ?? 0, backoffMs)
await res.body?.cancel()
await sleep(waitMs)
}
}Attempts are capped, so the loop cannot spin forever. A server delay longer than maxWaitMs returns the 429 to the caller instead of sleeping for minutes inside a request handler. OpenAI's guide makes the same call: if a valid server delay exceeds your maximum, stop retrying and defer the request.[4]
Run output
The wrapper ran on Node 22 against the local server shown below (bucket of 3 tokens, refilling 1 per second). Six sequential requests with a 100 ms base delay:
req 1: 200 after 19 ms
req 2: 200 after 3 ms
req 3: 200 after 2 ms
req 4: 200 after 1005 ms
req 5: 200 after 1003 ms
req 6: 200 after 1003 msRequests 4 through 6 each received a 429 with Retry-After: 1, slept slightly over a second, and succeeded on the retry. The 100 ms backoff alone would have retried too early and burned attempts, which is the point of the floor. A POST to the same exhausted bucket came back as a 429 with no retry.
Only retry what is safe to repeat
RFC 9110 defines a method as idempotent when multiple identical requests have the same intended effect on the server as a single one. PUT, DELETE and the safe methods are idempotent, and the safe methods defined by the spec are GET, HEAD, OPTIONS and TRACE.[2] It also says a client SHOULD NOT automatically retry a request with a non-idempotent method unless it has some means to know the request semantics are actually idempotent, or some means to detect that the original request was never applied.[2]
RFC 6585 does not say whether a server did any work before it sent the 429.[1] So a POST that creates an order or sends an email is the case to protect. Retry it only if the API documents a way to deduplicate (for example a client-supplied key), and set retryUnsafe only then. OpenAI adds two related warnings: do not automatically replay a streaming request after output has been consumed, and do not retry quota or billing errors that need you to act.[4]
What breaks: common mistakes
| Mistake | What happens | Fix |
|---|---|---|
| Fixed 1-second retry, no jitter | Every client that failed together retries together, and the spike repeats | Full jitter plus a growing cap |
| Ignoring Retry-After | Retries land before the window opens. Failed attempts count against your limit[4] | Delay = max(server hint, jittered backoff) |
| Parsing Retry-After as an integer only | A date value turns into NaN and the sleep becomes 0 | Accept delay-seconds and HTTP-date |
| Retrying a spend or quota 429 | Anthropic's monthly spend-cap 429 has no retry-after header, and retries, including the SDK's automatic ones, fail until access resumes[3] | Read the error code (enforced_spend_limit_reached) and stop |
| Nested retry loops | An SDK that retries inside your own retry loop multiplies requests. OpenAI says to disable SDK retries or account for them[4] | Retry in exactly one layer |
| No attempt or time budget | One stuck dependency holds threads or workers indefinitely | Cap attempts and total retry time |
| Hammering while limited | GitHub warns that continuing to make requests while rate limited may result in the banning of your integration[5] | Pause the whole worker pool, not one request |
Not every 429 carries Retry-After. Anthropic's docs say so directly.[3] GitHub adds a wrinkle: for a secondary limit with no retry-after and a nonzero x-ratelimit-remaining, wait at least one minute, then wait exponentially longer between retries and throw after a set number of retries.[5] And GitHub can answer a primary-limit hit with 403 as well as 429, so check headers, not just the status.[5] For a worked failure case in a coding agent, see the Codex 429 exceeded retry limit breakdown.
Vendor header reference
Bookmark-worthy, because every vendor spells these differently. All rows come from the vendors' own docs.
| Header | Vendor | Meaning |
|---|---|---|
Retry-After | RFC 9110, OpenAI, Anthropic, GitHub | Seconds to wait (or an HTTP-date per the RFC). Minimum wait, per OpenAI. Not on every 429[2][3][4] |
x-ratelimit-remaining | GitHub | Requests left in the current window. 0 on a primary-limit hit[5] |
x-ratelimit-reset | GitHub | Window reset time in UTC epoch seconds[5] |
x-ratelimit-remaining-requests, x-ratelimit-remaining-tokens | OpenAI | Remaining requests or tokens before the limit is exhausted[4] |
x-ratelimit-reset-requests, x-ratelimit-reset-tokens | OpenAI | Time until the limit resets, as a duration such as 1s or 6m0s[4] |
anthropic-ratelimit-requests-remaining (and -input-tokens-, -output-tokens- variants) | Anthropic | Remaining capacity before being rate limited[3] |
anthropic-ratelimit-requests-reset (and token variants) | Anthropic | When the limit is fully replenished, in RFC 3339 format[3] |
Reset values come as epoch seconds on GitHub, durations on OpenAI and timestamps on Anthropic. A shared client needs one parser per vendor. The IETF is working on a common format: draft-ietf-httpapi-ratelimit-headers defines RateLimit-Policy and RateLimit header fields. As of November 29, 2026, the datatracker lists it as an active Internet-Draft at revision 12 (last updated November 20, 2026), a working group document with IESG state "I-D Exists".[6] It is not an RFC, so do not depend on those headers being present.
429 vs 503
RFC 9110 says 503 Service Unavailable means the server is currently unable to handle the request due to a temporary overload or scheduled maintenance, and it MAY send Retry-After. The same section notes that a server under load does not have to use 503; some simply refuse the connection.[2] The split in practice: 429 is about you (your quota, your rate), and 503 is about the server's capacity.
OpenAI's current guide shows the split on one API. A 429 with code slow_down means your request rate increased too quickly, while a 503 with server_is_overloaded means the model is temporarily overloaded. For both, follow Retry-After when present.[4] The retry code is the same either way: extend the status check in the wrapper to include 503 if your API behaves this way, and keep the idempotency rule.
Sending a good 429 from your own server
RFC 6585 asks for details in the body and allows a Retry-After header.[1] A useful 429 does four things: it names the limit that was hit, gives a wait time computed from your actual counter, marks the response uncacheable, and uses a stable error code so clients can tell a rate limit from a quota. The server below is a token bucket with capacity 3 and a refill of one token per second, which is what produced the run output above.
import http from 'node:http'
// Token bucket per client: capacity 3, refills 1 token per second.
const CAPACITY = 3
const REFILL_PER_SEC = 1
const buckets = new Map()
function take(key, now = Date.now()) {
const b = buckets.get(key) ?? { tokens: CAPACITY, last: now }
b.tokens = Math.min(CAPACITY, b.tokens + ((now - b.last) / 1000) * REFILL_PER_SEC)
b.last = now
buckets.set(key, b)
if (b.tokens >= 1) {
b.tokens -= 1
return { ok: true }
}
const retryAfter = Math.ceil((1 - b.tokens) / REFILL_PER_SEC) // whole seconds, rounded up
return { ok: false, retryAfter }
}
export const server = http.createServer((req, res) => {
const key = req.headers['x-api-key'] ?? req.socket.remoteAddress
const r = take(String(key))
if (!r.ok) {
res.writeHead(429, {
'Content-Type': 'application/json',
'Retry-After': String(r.retryAfter),
'Cache-Control': 'no-store',
})
res.end(JSON.stringify({ error: 'rate_limited', retry_after_seconds: r.retryAfter }))
return
}
res.writeHead(200, { 'Content-Type': 'application/json' })
res.end(JSON.stringify({ ok: true }))
})The wait time is the time until one full token exists, rounded up to whole seconds, so a client that sleeps exactly that long succeeds. A flat Retry-After: 60 on every rejection makes honest clients wait a minute when the bucket would have refilled in two seconds. Pick the key carefully: the sample uses an API key header, falling back to the remote address, and the RFC leaves that choice to you.[1] Behind a proxy the remote address is the proxy, so every client would share one bucket.
Because RFC 6585 says 429 responses MUST NOT be stored by a cache, send Cache-Control: no-store and check that your CDN does not override it.[1] If you are being flooded, answering every request costs resources, and the RFC says dropping connections can be more appropriate.[1]
Authentication errors look similar in logs but need different handling. The 401 vs 403 explainer covers them, and the status code lookup lists the rest of the 4xx family.
Sources
- RFC 6585, Additional HTTP Status Codes, section 4 and section 7.2, IETF, April 2012 (accessed November 29, 2026)
- RFC 9110, HTTP Semantics, sections 9.2.1, 9.2.2, 10.2.3 and 15.6.4, IETF, June 2022 (accessed November 29, 2026)
- Rate limits, Claude Platform Docs, Anthropic (accessed November 29, 2026)
- Rate limits, OpenAI API documentation (accessed November 29, 2026)
- Rate limits for the REST API, GitHub Docs (accessed November 29, 2026)
- RateLimit header fields for HTTP, draft-ietf-httpapi-ratelimit-headers-12, IETF Datatracker (accessed November 29, 2026)
Written by
WOWHOW
The WOWHOW team brings 14+ years of production engineering experience. Every tool and product in the catalog is built, tested, and curated in-house.
Monday memo · free
One insight, every Monday. 7am IST.
1 field report, 3 links, 1 tool we actually use. No fluff, no spam.
Beyond the writing
Need production-ready templates?
Free browser tools with no signup, plus premium dev templates and starter kits.
Comments · 0
Beta: comments are stored locally on your device and not visible to other readers.
No comments yet. Be the first to share your thoughts.