Retry-After

Retry-After is the server's explicit instruction for when a retry may succeed. It accompanies 429 Too Many Requests, 503 Service Unavailable and some redirects, and holds either a number of seconds (Retry-After: 30) or an HTTP date. Honouring it is the difference between a client that recovers and one that prolongs the outage it is waiting out.

How it works

The client parses the value — both forms are valid and both occur — and schedules the retry no earlier than that. Where the header is absent, the client falls back to its own backoff policy. Good clients also cap the wait, so a misconfigured server cannot park them for a day.

The misconception

That a retry loop with a fixed one-second sleep is "handling 429". Every client doing that hits the server again in lockstep the moment the window opens. Retry-After, where present, already tells you the right number; where absent, use backoff with jitter.

Try it here

GET /coffee/v1/rush-hour allows three requests per ten seconds and answers the fourth with 429 and Retry-After; GET /protocol/v1/maintenance answers every request with 503 and Retry-After: 30.

Sources

Other terms

All glossary terms · Testing techniques · All 39 mock REST APIs

Last updated