limit_req (request rate)
- Default status
- 503, set by
limit_req_status - How to recognize it
- Fails only when one client or key sends faster than the zone's
rateplusburst. Retrying a second later works
An nginx 503 is usually limit_req or limit_conn rejecting requests, a backend answering 503, or a deliberate return 503. Find which, with config to fix each.
nginx itself returns 503 in two documented ways: limit_req and limit_conn reject excess requests with 503 by default, and return 503 sends it on purpose. A third source is the proxied backend, whose 503 nginx passes through. Find which rule fired by testing a burst of requests, then set limit_req_status, tune burst, or fix the backend.
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.
return 503; line chooses it for maintenance. Only the third source is a real fault: a proxied server that answers 503 itself.limit_req (request rate)limit_req_statusrate plus burst. Retrying a second later workslimit_conn (concurrent connections)limit_conn_statuslimit_conn allows, for example during large downloadsreturn 503; or an error_page 503 maintenance blockproxy_pass)client --> nginx
|-- limit_req / limit_conn -> 503 (default code), request never reaches the backend
|-- return 503 -> 503, fixed response
'-- proxy_pass --> backend -> backend's own 503 passes back through nginxcurl -sS -o /dev/null -w "%{http_code}\n" https://httpbin.org/status/503
# expected: 503for i in $(seq 1 20); do
curl -sS -o /dev/null -w "%{http_code} " https://your-site.example/search/
done; echo
# Rate limit: a run of 200s, then 503s once the burst is used up
# return 503 or a dead backend: 503 every timecurl -sS -D - -o /dev/null https://your-site.example/ | grep -i -E "^HTTP|^retry-after|^server"
# If you intend this 503 as maintenance, retry-after must be presentThen read the config. Search for limit_req, limit_conn, return 503 and error_page 503 across nginx.conf and included files with nginx -T | grep -n -E "limit_req|limit_conn|return 503|error_page 503". If none of them cover the failing location, the 503 is the backend's, so move to its own logs. The 503 pages for Apache and the generic 503 Service Unavailable cover that side.
burst is zero. With a zero burst, two requests in quick succession from the same address can trip the limit, which is why a page that loads several assets from one path can hit 503. nodelay serves the burst immediately instead of spacing it out. The rejected status is configurable, and a dry run lets you measure before enforcing.http {
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
limit_req_status 429;
server {
location /search/ {
limit_req zone=one burst=5 nodelay;
}
}
}location /search/ {
limit_req zone=one burst=5;
limit_req_dry_run on;
}limit_req_dry_run appeared in nginx 1.17.1. In that mode requests are not limited, but excessive requests are still counted in the shared memory zone, and the $limit_req_status variable (1.17.6) reports PASSED, DELAYED, REJECTED or REJECTED_DRY_RUN. The default log level for refusals is error, set by limit_req_log_level. The connection limiter has matching limit_conn_status (default 503), limit_conn_dry_run and limit_conn_log_level.
proxy_pass targets a group of servers, nginx can try the next one if the first fails, but only for the cases you list. The default proxy_next_upstream error timeout; does not include http_503. The documentation also says a 503 response counts as an unsuccessful attempt toward max_fails only if http_503 is specified in that directive.max_fails=3 with fail_timeout=30sbackupproxy_next_upstream_timeout 10s0 turns the limit offnon_idempotent (not set above)POST, LOCK and PATCH requests are not passed on once sent to an upstream serverupstream backend {
server backend1.example.com max_fails=3 fail_timeout=30s;
server backend2.example.com max_fails=3 fail_timeout=30s;
server backup1.example.com backup;
}
server {
location / {
proxy_pass http://backend;
proxy_next_upstream error timeout http_503;
proxy_next_upstream_timeout 10s;
}
}error_page. The Retry-After header needs the always parameter: by default add_header only adds a header to responses with codes such as 200, 301 or 304, so without always it is silently skipped on a 503.After nginx -t and a reload, run the single-request curl above: you should see HTTP/2 503 or HTTP/1.1 503 and a retry-after: 3600 line. Remove the return 503; block to end maintenance.
server {
listen 80;
server_name example.com;
root /var/www/example;
error_page 503 /maintenance.html;
location / {
return 503;
}
location = /maintenance.html {
internal;
add_header Retry-After 3600 always;
}
}Google's documentation says 5xx and 429 responses prompt its crawlers to temporarily slow down, and that a 503 or 429 may carry Retry-After with a delay in seconds or a date. A rate limit does not know who is asking, so an aggressive limit_req can return 503 to a crawler as readily as to a visitor. Google also warns against serving these codes for longer than 1-2 days, because if the same URL keeps returning them for multiple days it may be dropped from the index. For finding affected URLs, see 5xx server errors.
3 questions people ask next, answered from the sources on this page.
The default for both limit_req_status and limit_conn_status is 503. Set limit_req_status 429; or limit_conn_status 429; in the http, server or location block to return 429 instead.
Not by default. proxy_next_upstream defaults to error timeout, so a 503 response is passed back to the client. Add http_503 to that directive to try the next server in the upstream group.
add_header only applies to certain response codes unless you add always. Write add_header Retry-After 3600 always; and keep it in the same location or level that serves the 503, because headers are inherited only when a level has no add_header of its own.
Run the free audit, then approve the fixes. Every change can be undone.