Skip to content

How to Fix HTTP 429 Too Many Requests (Rate Limit) Error

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about How to Fix HTTP 429 Too Many Requests (Rate Limit) Error. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

Your API client receives:

HTTP/1.1 429 Too Many Requests

Or:

429 Too Many Requests: You have exceeded the rate limit. Please retry after the specified time.

The server has rate-limited your client because you sent too many requests in a given time window.

Quick Fix

1. Implement exponential backoff

Retry with increasing delays between attempts:

async function fetchWithRetry(url, options, maxRetries = 5) {
  for (let i = 0; i < maxRetries; i++) {
    const response = await fetch(url, options)
    if (response.status !== 429) return response
    const retryAfter = response.headers.get('Retry-After') || Math.pow(2, i) * 1000
    await new Promise(r => setTimeout(r, retryAfter * 1000))
  }
  throw new Error('Max retries exceeded')
}

2. Check rate limit headers

Use the headers returned by the API to pace requests:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1623456789
Retry-After: 60
const remaining = response.headers.get('X-RateLimit-Remaining')
const reset = response.headers.get('X-RateLimit-Reset')
// Wait until reset time or send fewer requests

3. Queue and throttle requests

Use a queue to limit concurrency:

// Use a queue to limit to 10 requests per second
const pLimit = require('p-limit')
const limit = pLimit(10)  // max 10 concurrent

const results = await Promise.all(
  items.map(item => limit(() => fetch(`/api/items/${item}`)))
)

4. Increase the rate limit

If you need more requests, request a higher limit from the API provider:

# Check the current plan limits in the API dashboard
open https://api.example.com/dashboard/rate-limits

Many APIs offer higher rate limits on paid tiers.

5. Batch requests

Some APIs support batch endpoints to reduce request count:

# Wrong — 100 individual requests
for id in {1..100}; do
  curl "https://api.example.com/users/$id"
done

# Right — single batch request (if supported)
curl -X POST "https://api.example.com/users/batch" \
  -H "Content-Type: application/json" \
  -d '{"ids": [1, 2, 3, ..., 100]}'

Prevention

  • Implement exponential backoff with jitter in all API clients.
  • Monitor rate limit headers and log warnings before hitting limits.
  • Use request queuing to smooth out traffic spikes.
  • Cache API responses where possible to reduce request volume.
  • Review your API usage regularly and upgrade the plan if needed.

Common Mistakes with 429 rate limit

  1. Using head and tail instead of pattern matching, causing runtime errors on empty lists
  2. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
  3. Using return to exit a function early instead of wrapping a pure value in the monad

These mistakes appear frequently in real-world API code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What is the Retry-After header?

The Retry-After header tells the client how many seconds to wait before retrying. Always respect this value. The header may be a decimal number or an HTTP-date.

What is the difference between 429 and 503?

429 means the client has exceeded its rate limit. 503 means the server is overloaded or down for maintenance. Both can be retried, but the retry Strategy differs.

How do I find my rate limit without making a request?

Many APIs document their rate limits in the API reference or developer portal. You can also check the X-RateLimit-Limit header in any response to see your limit.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro