Skip to content

Did you know?

Nginx rate limiting (limit_req) rejects requests with 503 by default, not 429.

Add limit_req_status 429; so rate-limited clients get 429 Too Many Requests instead of a misleading 503.

Explained

When a client goes over a limit_req zone, Nginx answers with 503 Service Unavailable unless you say otherwise. That tells clients the server is down or overloaded, so monitoring raises alarms and well-behaved API clients don’t know they should simply slow down.

Add limit_req_status (and limit_conn_status if you limit connections) next to the limit to return the correct 429 Too Many Requests:

limit_req zone=api burst=20 nodelay;
limit_req_status 429;

Then run sudo nginx -t and reload Nginx. Clients that handle 429 properly, including curl --retry, will now back off and retry instead of treating your site as broken.

Learn more

← All tech tips · Suggest a fix

Back to top