Skip to main content
503Retryable

Anthropic 503 Service Unavailable

The service (or an intermediary like Cloudflare) is temporarily unable to handle the request — distinct from 529 which is Anthropic's explicit overload signal.

Most likely causes

  1. 1.Brief deploy/infrastructure blip at the edge
  2. 2.Upstream incident in progress
  3. 3.Long-lived connection severed by a proxy

Fix checklist

  • Retry with backoff; treat like a 500
  • For streaming, resume with a fresh request rather than waiting on a dead socket
  • Check the status page if sustained

Retry guidance

Exponential backoff from 1s with jitter; cap retries at 3-4 then alert.

// Retry 503 with exponential backoff + full jitter.
async function callWithBackoff(payload: unknown, maxAttempts = 5) {
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
    const res = await fetch("https://api.anthropic.com/v1/messages", {
      method: "POST",
      headers: {
        "content-type": "application/json",
        "x-api-key": process.env.ANTHROPIC_API_KEY!,
      "anthropic-version": "2023-06-01",
      },
      body: JSON.stringify(payload),
    });
    if (res.status !== 503) return res;
    // Honor Retry-After when present; otherwise exponential backoff, capped at 32s.
    const retryAfter = Number(res.headers.get("retry-after"));
    const base = Number.isFinite(retryAfter) && retryAfter > 0
      ? retryAfter * 1000
      : Math.min(1000 * 2 ** attempt, 32_000);
    await new Promise((r) => setTimeout(r, base * (0.5 + Math.random() * 0.5)));
  }
  throw new Error("Anthropic 503: still failing after backoff — check https://status.anthropic.com");
}

Provider status page: status.anthropic.com