Skip to main content

HTTP 408 Request Timeout

The server timed out waiting for the complete request.

4xx · Client error✓ retryable with backoff

In AI APIs specifically

Large request bodies (long contexts, base64 images) over slow links can trip server read timeouts.

Fix checklist

  • Retry — safe by definition since the request never completed.
  • Compress or trim oversized payloads.
  • Check client-side connection pooling for half-dead sockets.

Retry handler (TypeScript)

async function fetchWithRetry(url: string, init: RequestInit, maxRetries = 5) {
  for (let attempt = 0; ; attempt++) {
    const res = await fetch(url, init);
    // 408 is retryable — back off and try again.
    if (res.status !== 408 || 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