limit_req_status
- Default
503- What it sets
- The status for requests rejected by
limit_req
Fix or configure an nginx 429 Too Many Requests: nginx rate limits return 503 by default, so learn limit_req_status, burst, nodelay and Retry-After.
nginx returns 429 Too Many Requests only when you set it: its rate limiting modules answer 503 by default, so a 429 comes from limit_req_status 429, limit_conn_status 429 or from the app behind nginx. A client crossed a configured rate or connection limit. Check limit_req_zone, burst and the key, and send a Retry-After header.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
limit_req_status503limit_reqlimit_conn_status503limit_connlimit_req_log_levelerrorSo if your site shows 503 under load and you expected 429, change the status. If it shows 429 and you never set it, the 429 comes from the app behind nginx, from a CDN, or from another rule. nginx's $upstream_status variable holds the upstream's status code, so logging it separates the two.
rate=1r/sr/m for less than one request per second; 30r/m is half a request per secondburst=5nodelaydelay=number$binary_remote_addr counts per client IP. Requests with an empty key are not accounted10m holds roughly 80 to 160 thousand. When the zone is full, nginx removes the least recently used statehttp {
limit_req_zone $binary_remote_addr zone=perip:10m rate=1r/s;
limit_req_status 429;
server {
location /search/ {
limit_req zone=perip burst=5 nodelay;
add_header Retry-After 1 always;
}
}
}add_header only adds a field for listed success and redirect codes unless you add always, so Retry-After needs always to appear on the 429. RFC 6585 says a 429 response "MAY include a Retry-After header indicating how long to wait before making a new request".
for i in $(seq 1 12); do
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/search/
doneWith the first config, if the loop finishes within about a second, the first six requests should pass (one at the rate plus a burst of five) and later ones return 429 with Retry-After. Rejected requests are logged at error level, so they appear in the default error log. For a related overload code, see 503 Service Unavailable; Google's status code documentation groups 429 with the 5xx errors for crawl-rate purposes, and 5xx server errors covers the crawl impact.
map $remote_addr $limit_key {
203.0.113.10 ""; # trusted: empty key is not counted
default $binary_remote_addr;
}
limit_req_zone $limit_key zone=perip:10m rate=5r/s;4 questions people ask next, answered from the sources on this page.
Find the limit_req or limit_conn rule that fired, then raise the rate, add or raise burst, or exempt trusted clients with an empty key. If the 429 comes from the app behind nginx, fix the limit there; $upstream_status shows which.
The default for both limit_req_status and limit_conn_status is 503. Set the directive to 429 to return that status.
The Retry-After header, if the server sends one, says how long. RFC 6585 says a 429 response may include it, and in nginx you add it with add_header ... always.
As a visitor you sent more requests than the site allows in a given time, so slow down or wait. As the site owner, the limit is your configuration.
Run the free audit, then approve the fixes. Every change can be undone.