The short answer: retry 408, 425, 429, 502, 503 and 504, be careful with 500 and 409, and don't retry other 4xx errors. Here's each one, and why.
408 Request TimeoutRetry
The server gave up waiting for the request. The spec says the client may repeat it.
409 ConflictIt depends
Usually a real conflict with the resource's state, which retrying won't fix. Some APIs use it for lock contention; the OpenAI and Anthropic SDKs retry it.
425 Too EarlyRetry
The server won't process a request sent in TLS early data. Retry after the handshake completes.
429 Too Many RequestsRetry
You're being rate limited. Wait for Retry-After if it's present, otherwise back off.
500 Internal Server ErrorIt depends
Often transient. Safe to retry for idempotent requests (GET, PUT, DELETE) or a POST with an idempotency key; a plain POST may already have taken effect.
502 Bad GatewayRetry
A proxy got a bad answer from upstream. Usually transient. Same idempotency caution as 500.
503 Service UnavailableRetry
Overloaded or down for maintenance. Honor Retry-After if present.
504 Gateway TimeoutRetry
A proxy timed out waiting for upstream. The upstream may still have done the work, so the same idempotency caution applies.
400 Bad RequestDon't retry
The request is malformed. Sending it again gets the same answer.
401 UnauthorizedDon't retry
Credentials are missing or wrong. Refresh the token once if you can, then stop.
403 ForbiddenDon't retry
You're not allowed. Retrying won't change that.
404 Not FoundDon't retry
Unless you just created the resource in an eventually consistent system, it isn't coming back.
405 Method Not AllowedDon't retry
The method isn't supported on this URL.
410 GoneDon't retry
Removed on purpose, and the server is saying so.
413 Content Too LargeDon't retry
Make the request smaller instead. (A Retry-After here means the limit is temporary.)
422 Unprocessable ContentDon't retry
The request is well formed but invalid, like a declined card or a failed validation.
501 Not ImplementedDon't retry
The server doesn't support the feature at all.
Three rules that matter more than the list
- Only repeat what's safe to repeat. GET, HEAD, PUT and DELETE are idempotent by definition (RFC 9110). For a POST that charges a card or sends an email, send an
Idempotency-Key header and keep it the same on every retry, if the API supports one. - Let the server set the pace. When a 429 or 503 carries
Retry-After, wait that long (check a value with the Retry-After parser). Otherwise back off exponentially with jitter (try the backoff calculator). - Give up eventually. Cap the number of attempts and the total time, then surface the error to the caller instead of hanging.
Check what your client really does
Most retry bugs only show up when a dependency actually fails. Jitterbox's resilience report watches your client against an API that fails on purpose and flags exactly these mistakes: no retry after a 429 or 5xx, a retry sooner than Retry-After, no backoff, too many attempts, a retried 400/401/403/404/405/410/413/422, and a dropped idempotency key. The guide How to test retry logic shows the setup.