# 5xx: their side, usually transient, retry properly

## The errors

- `500 Unknown`: internal server error.
- `502 Bad Gateway`: gateway got an invalid backend response.
- `503 Unavailable`: service temporarily unavailable.
- `504 Gateway Timeout`: backend too slow; can hit on heavy requests.

## Fix

Retry with exponential backoff and jitter, capped delay, max retries. The docs' retry guidance:

1. Retry only 5xx and 429. Never other 4xx.
2. Add jitter so a fleet of clients does not thunder-herd the recovery.
3. Log attempts with timestamps; you will need them if it persists.

The Go SDK has this built in via `RetryPolicy` (covers 429 and transient 5xx plus gRPC UNAVAILABLE). Python and Node need the loop in your code; write it once in a helper, not per call site.

## When to stop retrying and escalate

If 5xx persist beyond a few minutes across retries, collect: index name, project name, error messages and stack traces, timestamps, a minimal reproducible request, and whether it reproduces. Then contact support. That evidence list is straight from the docs' support guide.