---
title: "HTTP 429 Too Many Requests: handle it and send it right · CloudSat"
description: "HTTP 429 from both sides: back off with Retry-After and jitter as a client, then send clean 429s from Nginx with bursts, real client IPs and per-key limits."
url: https://cloudsat.io/learn/handle-and-send-http-429-rate-limits
updated: 2026-11-18T12:00:00Z
source: CloudSat (https://cloudsat.io/). Prices in USD.
---

[DevOps](https://cloudsat.io/learn/topic/devops-and-automation)

# HTTP 429 Too Many Requests: handle it and send it right

HTTP 429 from both sides: back off with Retry-After and jitter as a client, then send clean 429s from Nginx with bursts, real client IPs and per-key limits.

CloudSat team November 18, 2026 8 min read

A 429 is the most personal error in HTTP. It does not say the server is broken or the page is missing; it says this client asked too often. You meet it in two roles. As a client, an API or website throttles your script, bot or integration and you need to slow down correctly. As an operator, you send 429s to keep one noisy client from eating the capacity everyone else shares. Both roles depend on the same few rules.

## What a 429 says, and what it leaves open

RFC 6585 defines 429 Too Many Requests: the user has sent too many requests in a given amount of time. The response should explain the condition and may include a `Retry-After` header saying how long to wait. The RFC deliberately does not define how the server identifies the user or counts requests: per resource, across a whole server or a set of servers, by credentials, by cookie or by address. Two more rules matter in practice:

- A 429 response must not be stored by a cache.
- `Retry-After`, defined in RFC 9110, holds either a number of seconds or an HTTP date.

Many APIs also send quota headers. Most use their own `X-RateLimit-*` names and meanings, so read each provider's documentation. An IETF draft defines standard `RateLimit` and `RateLimit-Policy` fields, but it is still an Internet-Draft (revision 11, May 2026), not an RFC.

| Status | What it means | What a client should do |
| --- | --- | --- |
| 429 | This client exceeded a rate or quota | Wait as told, then slow down |
| 503 | The service is unavailable or overloaded for everyone | Retry later, honoring `Retry-After` if present |
| 403 | Refused, whatever the rate | Do not retry; fix credentials or permissions |

## When you are the client

### Read Retry-After first

If the server tells you when to come back, that is the only number that matters. Guessing shorter just earns more 429s.

### Back off with jitter

Without a hint, wait exponentially longer between attempts and add randomness. Jitter matters more than it looks: when an API recovers from an outage, many clients retrying on the same schedule hit it in the same second and knock it over again. Cap both the delay and the number of attempts.

```python
import random
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime

import requests

def retry_after_seconds(value):
    """Seconds to wait from a Retry-After header, or None."""
    if not value:
        return None
    value = value.strip()
    if value.isdigit():
        return int(value)
    try:
        when = parsedate_to_datetime(value)
    except (TypeError, ValueError):
        return None
    return max(0.0, (when - datetime.now(timezone.utc)).total_seconds())

def get_with_backoff(url, attempts=6, base=1.0, cap=60.0):
    for attempt in range(attempts):
        resp = requests.get(url, timeout=30)
        if resp.status_code != 429 and resp.status_code < 500:
            return resp
        if attempt == attempts - 1:
            break
        wait = retry_after_seconds(resp.headers.get("Retry-After"))
        if wait is None:
            wait = random.uniform(0, min(cap, base * 2 ** attempt))
        time.sleep(min(wait, cap))
    resp.raise_for_status()
```

For shell scripts, curl does the same work. With `--retry`, it treats 429 and several 5xx codes as transient, starts at one second and doubles the delay, and it has honored `Retry-After` since version 7.66.0:

```bash
curl -sS --retry 5 --retry-max-time 120 -o items.json https://api.example.com/v1/items
```

### Spend fewer requests

The cheapest request is the one you never send. Cache responses you reuse, send conditional requests with `If-None-Match` so unchanged data comes back as a short 304, use batch endpoints where they exist, and switch from polling to webhooks when the API offers them. If several workers share one API key, they share one quota: route their calls through a single queue instead of letting each one discover the limit on its own.

### Retry only what is safe to repeat

A GET can be retried freely. A POST that timed out may already have been processed, so retrying it can create a duplicate order or message. Retry idempotent methods, or send the idempotency key the API supports; our guide to [PUT, PATCH and safe retries](https://cloudsat.io/learn/put-or-patch-for-api-updates) covers which methods are safe.

## When you are the server: Nginx

Nginx's `limit_req` module meters requests per key with a leaky bucket. The zone sets the key and the steady rate, in requests per second (`r/s`) or per minute (`r/m`). Each `limit_req` line then decides what happens to a burst above that rate:

| Setting | Requests above the rate, up to the burst | Beyond the burst |
| --- | --- | --- |
| `burst=20` | Queued and released at the zone's rate | Rejected |
| `burst=20 nodelay` | Served at once; the slots refill at the rate | Rejected |
| `burst=20 delay=10` | First 10 served at once, the next 10 queued | Rejected |

Rejected requests get 503 by default, which tells clients the service itself is unavailable. Change it to 429 and send a `Retry-After` the client can use:

```nginx
# http context
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
limit_req_status 429;
limit_req_log_level warn;

server {
    # listeners and certificates as usual
    location /api/ {
        limit_req zone=api burst=20 delay=10;
        error_page 429 = @too_many;
        proxy_pass http://127.0.0.1:8080;
    }

    location @too_many {
        default_type application/json;
        add_header Retry-After 5 always;
        return 429 '{"error":"too_many_requests","retry_after":5}\n';
    }
}
```

A 10 MB zone is generous: the documentation puts one megabyte at about 8,000 states on 64-bit systems. Limit dynamic paths such as APIs, search and login forms, not static files; a single page view can request dozens of images and scripts.

### Count the real client, not the proxy

Behind a CDN, a load balancer or a reverse proxy, every request arrives from the proxy's address, so one shared bucket throttles all your visitors at once. Restore the client address from the forwarded header, trusting only your proxy's ranges:

```nginx
set_real_ip_from 198.51.100.0/24;   # your proxy or CDN ranges only
real_ip_header X-Forwarded-For;
real_ip_recursive on;
```

### Limit by key, not only by address

Nginx does not count requests whose key is empty. A `map` can use that to rate limit anonymous traffic by address while leaving authenticated requests to the application, which knows the account:

```nginx
map $http_authorization $anon_key {
    ""      $binary_remote_addr;
    default "";
}
limit_req_zone $anon_key zone=anon:10m rate=2r/s;
limit_req_zone $binary_remote_addr zone=everyone:10m rate=50r/s;
```

Apply both zones with two `limit_req` lines in the same location. The looser `everyone` zone stays on because anyone can send a fake `Authorization` header.

### Try it in dry run first

`limit_req_dry_run on;` counts excess requests without rejecting anything, and the `$limit_req_status` variable records `PASSED`, `DELAYED`, `REJECTED` or their dry-run variants. Add it to a log format, run for a few days of real traffic, and set the limits from what you see rather than from a guess.

## In the application

Per-account and per-plan quotas need identity, which only the application has. Return 429 with `Retry-After` and a body that names the limit that was hit. When several app instances share the work, keep the counters in Redis or Valkey so every instance sees the same numbers. A fixed window is the simplest version:

```python
import time
import redis

r = redis.Redis()

def allow(account_id, limit=100, window=60):
    bucket = int(time.time()) // window
    key = f"rl:{account_id}:{bucket}"
    pipe = r.pipeline()
    pipe.set(key, 0, ex=window, nx=True)
    pipe.incr(key)
    _, count = pipe.execute()
    retry_after = window - int(time.time()) % window
    return count <= limit, retry_after
```

Fixed windows let a client spend two windows' worth across a boundary. If that matters, move to a sliding window or a token bucket.

## Debugging a 429 you did not expect

1. **Find who answered.** If your origin's access log has no entry for the request, a CDN, WAF or API gateway in front of it sent the 429. Response headers often name that layer.
2. **Read Nginx's log.** Each rejection is logged with the zone and the client address: `sudo grep 'limiting requests' /var/log/nginx/error.log | tail`.
3. **Look for shared addresses.** An office, a mobile carrier's NAT or a VPN exit can put hundreds of people behind one IP. So can your own proxy without the `realip` settings above.
4. **Check your own jobs.** A cron task without backoff, a health check pointed at a limited path, or a fleet of workers restarting together can trip limits on your own server.

Trusted sources can skip the per-address zone with `geo`:

```nginx
geo $rl_exempt {
    default          0;
    198.51.100.0/24  1;   # office
    127.0.0.1        1;   # local health checks
}
map $rl_exempt $rl_key {
    0 $binary_remote_addr;
    1 "";
}
limit_req_zone $rl_key zone=perip:10m rate=10r/s;
```

If legitimate traffic keeps hitting your limits, the answer is capacity, not a lower limit: a CloudSat server can be [resized to a bigger plan](https://cloudsat.io/docs/resize-a-server) from the console.

## FAQ

### Should an overloaded server send 429 or 503?

503, when the whole service is struggling. 429 is for one client over its share. Sending 429 to everyone during an outage tells well-behaved clients that they did something wrong.

### Do 429s hurt search crawling?

Google's crawlers treat 429 as a sign that the server is overloaded and temporarily slow down. A short spike is harmless, but persistent errors can eventually drop indexed URLs. If you exempt crawlers, verify them with a reverse DNS lookup instead of trusting the user agent, which anyone can fake.

### What if a client ignores Retry-After?

Your limit still holds: the client simply keeps receiving 429s. If one address hammers the server for hours, block it in the firewall, where it costs less than an HTTP response.

### How do I pick the numbers?

Run the zone in dry run mode, look at the request rates of real clients in the logs, and set the rate above normal peaks with a burst sized for a page load or an app sync. Tighten login and password reset paths more than anything else.

**Run it on CloudSat.** Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. [See plans](https://cloudsat.io/plans) or [deploy a server](https://dash.cloudsat.io/console/deploy).

## Keep reading

[All guides in DevOps](https://cloudsat.io/learn/topic/devops-and-automation)

- [Caddy or Nginx as a reverse proxy for self-hosted apps](https://cloudsat.io/learn/caddy-or-nginx-reverse-proxy): DevOps Caddy or Nginx as a reverse proxy for self-hosted apps 8 min read
- [PUT or PATCH for API updates: semantics, retries, conflicts](https://cloudsat.io/learn/put-or-patch-for-api-updates): DevOps PUT or PATCH for API updates: semantics, retries, conflicts 7 min read
- [Nginx Proxy Manager on a VPS: setup and lockdown](https://cloudsat.io/learn/nginx-proxy-manager-setup-and-lockdown): Self-hosting Nginx Proxy Manager on a VPS: setup and lockdown 8 min read
- [Blue-green and canary releases on ordinary servers](https://cloudsat.io/learn/blue-green-and-canary-releases): DevOps Blue-green and canary releases on ordinary servers 6 min read
