HTTP 429 Too Many Requests: What It Means and How to Fix It
HTTP 429 Too Many Requests means the server is rate limiting you: you sent more requests than it allows in some window of time. It isn't a bug in your request. The fix is to wait the number of seconds in the response's Retry-After header, retry, and then send requests more slowly so you stop hitting the limit. This post covers what the status code means, the headers that tell you how long to wait, and a tested Python retry loop.
What does 429 Too Many Requests mean?
The 429 status code says the user has sent too many requests in a given amount of time, which is rate limiting. RFC 6585 defines it, and says the response should explain the condition and may include a Retry-After header saying how long to wait before making a new request (RFC 6585, 2012). The same RFC says a 429 response must not be stored by a cache.
The RFC deliberately leaves the counting to the server. It doesn't say how the server identifies "the user" or how it counts: a limit can apply per resource, across a whole server, or across a set of servers. In practice an API usually counts per API key or per account, and a website per IP address or session.
So a 429 tells you two things: your request was probably fine, and you sent it too soon. Retrying at once makes it worse, because every rejected request usually still counts against the limit.
Who is sending the 429, and is it you or them?
The 429 comes from whichever server enforces the limit, and that decides what you can do about it. If you call an API, its rate limit is in its docs and its headers, and you fix the 429 by slowing your client down. If you're a visitor on a website and see a 429 page, the site has decided your browser or network sent too many requests, and the only fix on your side is to wait.
Shared limits cause most surprises. When several scripts or workers use one API key, or one account, they draw on the same budget, so each one can be well under the limit while together they're over it. An office or a cloud provider's IP range can look like one heavy user to a website that limits by IP.
If you run the server and your own users see 429s, check the limit's scope first. A per-IP limit behind a proxy or load balancer may be counting every user as the proxy's address.
How do you read Retry-After and RateLimit headers?
Retry-After is the header to read first, because it's the server telling you exactly when to come back. RFC 9110 defines its value as either an HTTP date or a number of seconds to wait after receiving the response (RFC 9110, 2022). Servers also send it on 503 Service Unavailable responses, to say how long the service is expected to be down.
| Header | Example | What it tells you |
|---|---|---|
Retry-After |
17 or Wed, 21 Oct 2026 07:28:00 GMT |
When to retry |
RateLimit-Limit |
300 |
Requests allowed in the window |
RateLimit-Remaining |
12 |
Requests left in this window |
RateLimit-Reset |
17 |
Seconds until the window resets |
RateLimit-Policy |
300;w=60 |
The quota and the window length in seconds |
The RateLimit-* names come from the IETF HTTP APIs working group's draft on rate-limit headers. The current draft folds them into two structured fields, RateLimit-Policy and RateLimit (draft-ietf-httpapi-ratelimit-headers, 2026), and many APIs still send older names, often with an X- prefix. Read whichever your API documents, and treat them as hints: the draft itself says available quota is not a guarantee the next request will be served.
How do you fix a 429 in your code?
Retry the request after the wait the server asked for, and stop after a few attempts. The loop below handles Retry-After as seconds or as a date, falls back to exponential backoff when the header is missing, adds jitter, and gives up rather than sleeping for an unreasonable time. It retries only 429 and 503; other errors such as 400 or 401 won't fix themselves, so it returns them for your code to handle.
import random
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
import requests
RETRYABLE = {429, 503}
def retry_after_seconds(value):
"""Retry-After is either delay-seconds or an HTTP-date (RFC 9110)."""
if not value:
return None
if value.strip().isdigit():
return int(value)
try:
when = parsedate_to_datetime(value)
except (TypeError, ValueError):
return None
return max(0, (when - datetime.now(timezone.utc)).total_seconds())
def get_with_retry(url, params=None, headers=None, max_attempts=5, max_wait=120):
for attempt in range(1, max_attempts + 1):
resp = requests.get(url, params=params, headers=headers, timeout=60)
if resp.status_code not in RETRYABLE:
return resp
if attempt == max_attempts:
break
wait = retry_after_seconds(resp.headers.get("Retry-After"))
if wait is None:
wait = min(2 ** attempt, 60) # no header: exponential backoff
wait += random.uniform(0, 1) # jitter, so parallel workers don't retry in step
if wait > max_wait:
break
print(f"{resp.status_code}, waiting {wait:.1f}s (attempt {attempt})")
time.sleep(wait)
resp.raise_for_status()
return resp
We tested it against a local mock server that answered a 429 with Retry-After: 2, then a 503 with no header, then a 200:
429, waiting 2.9s (attempt 1)
503, waiting 5.0s (attempt 2)
final 200 after 3 requests
The first wait followed the header, the second fell back to backoff. Most HTTP clients have this built in under another name, such as urllib3's Retry with respect_retry_after_header, so check yours before writing your own. Handle Web Data API Errors in Python covers the other status codes.
How do you stop getting 429s in the first place?
Send requests no faster than the limit, and let one place in your code decide the pace. Retrying fixes the request in front of you; pacing fixes the cause.
- Know the number. Read the API's documented limit, or
RateLimit-LimitandRateLimit-Policy, and convert it to the unit you schedule in. - Throttle at the source. A token bucket or a semaphore in front of all workers keeps the total rate under the limit, however many workers you run. Concurrent API Requests in Python builds one with asyncio.
- Watch
RateLimit-Remaining. When it's low, sleep forRateLimit-Resetseconds before the next request rather than after a 429. - Don't fetch twice. Cache responses that don't change within your job, so repeated questions don't spend requests. Cache Web Data API Responses covers what to cache and for how long.
- Stagger scheduled jobs. If several of your jobs share a key and start in the same minute, they compete for the same window. Start them a few minutes apart.
For agents, put the cap in the tool layer, because a model in a loop can issue calls faster than you expect. MCP Server Rate Limiting shows where.
What does a 429 look like on Perceptlayer, and does it cost anything?
A 429 from Perceptlayer costs nothing. Rate limits are per account, shared by all its keys, and counted in a fixed one-minute window: a free account gets 1 request a second (60 a minute), and a paying account gets the rate of the credits it's using, at least 5 a second (300 a minute). When the window is full you get status 429, the error code rate_limited, X-Credits-Used: 0, and a Retry-After header with the seconds until the window resets.
curl -i "https://api.perceptlayer.com/v1/google-search/search?query=best+restaurants+in+Berlin&hl=en" \
-H "X-API-Key: $API_KEY"
We didn't run this request for this post. Responses also carry RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset and RateLimit-Policy, and the error body has the usual shape: {"error": {"code", "message", "request_id"}}. The rate limits docs list the rates per pack, and the errors docs list every code.
What does that mean for a batch job?
A free account can run 60 searches a minute. A job of 3,000 searches therefore needs at least 3,000 ÷ 60 = 50 minutes; paced at that rate it never sees a 429, and it costs 3,000 × 1 credit = 3,000 credits. At a paying account's 300 a minute the same job takes 10 minutes. Firing all 3,000 at once doesn't finish sooner: at most 60 succeed in a window and the rest are rejected with 429 until the window resets. See pricing for the rate each pack includes.
One caution for retries in general: a request that timed out on your side may still have succeeded on the server. Retry Web API Calls Without Paying Twice covers that case. To see the headers on a real response, run a search in the playground on the Google Search API page, or get a free API key and run the cURL above with -i.
APIs in this post
Frequently asked questions
How long should I wait after a 429?
Wait the number of seconds in the Retry-After header, or until the date it gives, plus a second of random jitter. If there's no header, back off exponentially: about 2 seconds, then 4, then 8, with a cap. Retrying immediately usually fails again, because rejected requests often count against the same limit.
Is a 429 error my fault or the server's?
Usually neither is broken. The server is enforcing a limit it chose, and your client exceeded it, often because several workers share one key or account. Slow the client down to the documented rate. A 429 on a website you're browsing means the site is limiting your browser or network; waiting a few minutes is the fix.
What is the difference between 429 and 503?
A 429 says you sent too many requests; a 503 says the server or the service behind it can't handle the request right now, whoever sent it. Both may carry Retry-After, and both are worth retrying after the wait. On Perceptlayer, neither costs credits: rate_limited (429) and temporarily_unavailable (503) both return X-Credits-Used: 0.
Does a 429 count against my credits?
Not on Perceptlayer. Only a successful response debits credits; a 429, like every other error, returns X-Credits-Used: 0 and still reports X-Credits-Remaining. On other APIs, check the docs: some count rejected requests toward a daily quota even when they don't bill for them.
Should I retry a 429 forever?
No. Cap the attempts (five is plenty) and the longest wait you'll accept, then fail and log it. A 429 that persists after the reset means your overall rate is too high, and more retries only add load. Fix the pace instead: throttle all workers through one limiter set below the documented limit.