HTTP status code lookup

429 Too Many Requests: Meaning, Retry-After and Fixes

A 429 Too Many Requests response means the server is rate limiting you: you sent more requests than it allows in a period of time. The request was not processed, and you should wait before sending more.

429

Too Many Requests

The client sent too many requests in a given time (rate limiting).

Look up any other status code →

Read the response headers

  • Retry-After tells you how long to wait, either as a number of seconds (Retry-After: 30) or as a date. Always respect it when it's there.
  • Many APIs also send the limit and what's left of it, under names such as X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset, or the newer RateLimit and RateLimit-Policy headers. Check the API's documentation for which ones it uses.

Retry with exponential backoff

Wait longer after each failed attempt, and add random jitter so many clients don't retry at the same moment:

async function fetchWithRetry(url, options = {}, attempts = 5) {
  for (let attempt = 0; ; attempt++) {
    const response = await fetch(url, options);
    if (response.status !== 429 || attempt >= attempts - 1) return response;

    const retryAfter = Number(response.headers.get("Retry-After"));
    const backoff = 2 ** attempt * 1000 + Math.random() * 1000;
    const wait = Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter * 1000 : backoff;
    await new Promise((resolve) => setTimeout(resolve, wait));
  }
}

Send fewer requests

  • Cache responses that don't change often instead of fetching them again.
  • Use the API's batch or bulk endpoints when it has them.
  • Limit how many requests run in parallel, for example 5 at a time, rather than starting hundreds with Promise.all.
  • Debounce requests triggered by typing, such as search-as-you-type.
  • Use webhooks instead of polling if the API offers them.

Returning 429 from your own API

Send a Retry-After header with the 429 so clients know when to come back, and include the limit in the response body or headers. Rate limit per API key or user where possible, rather than per IP address, which many users can share.

Frequently asked questions

How long should I wait after a 429?

As long as Retry-After says. Without it, start at about a second and double the wait after each further 429, up to a limit.

Why do I get 429 when I'm barely sending requests?

The limit may be shared, for example across all users behind the same IP address or across all the apps using one API key. Some limits are also counted per day, not per minute.

Is 429 the same as 503?

No. 429 says you in particular are sending too much. 503 Service Unavailable says the server is overloaded or down for everyone.

More http status code lookup guides

Open the full http status code lookup →

From the blog