HTTP 429 Too Many Requests means the client has sent more requests than the server allows in a given time, and this one was refused. It is defined in RFC 6585 and is the standard answer of a rate limiter. The request itself was valid: the same request would succeed once you slow down.
What a 429 response looks like
HTTP/1.1 429 Too Many Requests
Retry-After: 30
Content-Type: application/json
{"error":"rate_limited","message":"Limit is 100 requests per minute"}
Retry-After is the part that matters. It is either a number of seconds (30) or an HTTP date, and it tells the client when to try again. The RFC makes the header optional, so check the documentation of the API you call. Many APIs add their own headers such as X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset; the names differ from one provider to another, and a standard form is still being worked out.
Why you get a 429
- A loop or a retry storm in your own code: a bug that calls the API on every render, or a retry without a delay that multiplies the problem.
- Many users behind one address: an office, a school or a mobile carrier can share one IP, and a limiter that counts per IP sees them as one client.
- A plan quota: free keys often get a few requests per second or a daily cap.
- Protection on login and search endpoints: they are limited more strictly than the rest of the site.
- Bots and crawlers that read pages faster than a person would.
How to fix it as a client
- Read
Retry-Afterand wait at least that long before the next request to the same API. - Without the header, back off exponentially with jitter: wait about 1 s, then 2 s, 4 s, 8 s, each time multiplied by a random factor between 0.5 and 1. Give up after a few tries.
- Send fewer requests: batch several operations into one call, cache the answers you already have, and use webhooks or
If-None-Matchinstead of polling. - Queue the work so that your own program never exceeds the documented rate.
async function fetchWithBackoff(url, tries = 5) {
for (let i = 0; i < tries; i++) {
const res = await fetch(url);
if (res.status !== 429) return res;
const header = Number(res.headers.get('Retry-After')); // NaN when it is a date: fall back to backoff
const ms = header > 0 ? header * 1000 : Math.min(30_000, 2 ** i * 1000) * (0.5 + Math.random() / 2);
await new Promise((resolve) => setTimeout(resolve, ms));
}
throw new Error('Still rate limited after several tries');
}
A 429 means the request was refused before it ran, so retrying it is normally safe, even for a POST. Confirm that in the provider’s documentation. To reproduce a failing call outside your program, paste the curl command into the curl converter and turn it into code with the retry logic you need.
How to send a good 429 as a server
- Use 429 for a limit that applies to one client, not 403 (which says “never”) and not 503 (which says “the server is struggling”).
- Always send
Retry-After, and put the limit in the body in words a developer can act on. - Limit by API key or user where you can, and by IP only as the fallback, so a shared address does not lock out everyone.
- Do not let the limiter itself become the load: reject early, before you do any expensive work.
Related codes
The HTTP status codes tool finds related codes by words: search for rate limit and it lists 429 and the old Twitter-specific 420 “Enhance Your Calm”. For the server-side counterpart read 503 Service Unavailable, and for a limit that is really a permission problem, 403 Forbidden.
Frequently asked questions
Is a 429 my fault or the server's?
It is about the rate of your requests, so the fix is on the client side: slow down, cache, or ask for a higher quota. The server is working as designed. The exception is a limiter that is set too low or counts many users behind one IP address as a single client.
How long should I wait after a 429?
As long as the Retry-After header says. If the header is missing, wait one second, then two, then four, and so on, and add a random delay so that many clients do not retry at the same moment.
Should a server send 429 or 503 when it is overloaded?
Send 429 when one client is sending too much, and 503 when the server is overloaded or down for everyone. Clients and search engines treat them differently: 429 says slow down, 503 says come back later.
Does a 429 hurt my site in search?
A few of them do no harm, but Google slows down crawling when it sees many 429, 500 and 503 responses. If Googlebot gets rate limited by your own protection layer, loosen the rule for verified crawlers.
More in this reference
- HTTP 301 Moved Permanently: redirects, caching and SEO
- HTTP 302 Found: temporary redirects, and when to use 303 or 307 instead
- HTTP 304 Not Modified: how conditional requests and ETags save bandwidth
- HTTP 400 Bad Request: the common causes and how to find the bad part
- HTTP 401 Unauthorized: missing or invalid credentials, and 401 vs 403
- HTTP 403 Forbidden: why access is refused and how to fix it
- HTTP 404 Not Found: causes, how to debug it and what to return instead
- HTTP 500 Internal Server Error: how to find the cause and what to tell users
- HTTP 502 Bad Gateway: finding the broken link between the proxy and the app
- HTTP 503 Service Unavailable: maintenance pages, overload and Retry-After
- HTTP 504 Gateway Timeout: why the proxy gave up waiting, and the timeouts to check