Error Encyclopedia
429

429 Too Many Requests Error

Learn what 429 Too Many Requests means, how rate limiting works, and how to handle or avoid hitting API rate limits.

What Does This Error Mean?

The 429 Too Many Requests status code means the user has sent too many requests in a given amount of time (rate limiting). The server is protecting itself from abuse by temporarily blocking further requests.

Common Causes

1

Sending requests faster than the API rate limit allows

2

Missing delay between retry attempts in a loop

3

Multiple instances or threads not sharing rate limit state

4

No backoff strategy when retrying failed requests

5

Aggressive polling or web scraping without throttling

6

DDoS protection systems (Cloudflare, AWS WAF) blocking legitimate traffic

How to Fix It

Implement exponential backoff

When you get a 429, wait increasing amounts of time before retrying.

async function fetchWithRetry(url, retries = 3) {
  for (let i = 0; i < retries; i++) {
    const res = await fetch(url)
    if (res.status === 429) {
      const retryAfter = res.headers.get("Retry-After") || Math.pow(2, i) * 1000
      await new Promise(r => setTimeout(r, Number(retryAfter) * 1000))
      continue
    }
    return res.json()
  }
  throw new Error("Rate limited after retries")
}

Check rate limit headers

Many APIs include headers that tell you your current rate limit status.

// Common rate limit headers
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 42
X-RateLimit-Reset: 1640995200
Retry-After: 60

Add request queuing

Queue requests and send them at a controlled rate to avoid bursts.

class RateLimiter {
  constructor(limit, interval) {
    this.queue = []
    this.tokens = limit
    setInterval(() => { this.tokens = Math.min(this.tokens + 1, limit) }, interval / limit)
  }
  async request(fn) {
    while (this.tokens <= 0) await new Promise(r => setTimeout(r, 100))
    this.tokens--
    return fn()
  }
}

Before & After Examples

❌ Before
for (let i = 0; i < 1000; i++) {
  await fetch("/api/items/" + i) // Hits rate limit immediately
}
✅ After
const limiter = new RateLimiter(10, 1000) // 10 requests per second
for (let i = 0; i < 1000; i++) {
  await limiter.request(() => fetch("/api/items/" + i))
}

Related Tools

Use these tools to debug and fix this error:

Related Errors

Other common errors in this category:

Frequently Asked Questions

How long should I wait after a 429?

Check the Retry-After header which tells you exactly how many seconds to wait. If it's not provided, use exponential backoff starting at 1 second.

Is 429 the same as rate limiting?

Yes. 429 is the standard HTTP status code for rate limiting. Some services may return 503 Service Unavailable instead, but 429 is the correct semantic status.