Skip to main content

HTTP 503 Service Unavailable

The server is temporarily unable to handle the request — overload or maintenance. May include Retry-After.

5xx · Server error✓ retryable with backoff

In AI APIs specifically

Providers return 503 during capacity crunches; Anthropic distinguishes its overload state with the dedicated 529 code instead.

Fix checklist

  • Honor Retry-After when present.
  • Back off aggressively — hammering a 503 makes the outage worse.
  • Fail over to a secondary model or provider if your stack supports routing.

Retry handler (TypeScript)

async function fetchWithRetry(url: string, init: RequestInit, maxRetries = 5) {
  for (let attempt = 0; ; attempt++) {
    const res = await fetch(url, init);
    // 503 is retryable — back off and try again.
    if (res.status !== 503 || attempt >= maxRetries) return res;
    const retryAfter = Number(res.headers.get("retry-after"));
    const delay = Number.isFinite(retryAfter) && retryAfter > 0
      ? retryAfter * 1000
      : Math.min(60_000, 1000 * 2 ** attempt) * (0.5 + Math.random()); // expo backoff + jitter
    await new Promise((r) => setTimeout(r, delay));
  }
}

Spec: RFC reference