Skip to main content
HTTP 499 Client Closed Request
Non-standard (nginx): the client disconnected before the server finished responding.
4xx · Client error✓ retryable with backoff
In AI APIs specifically
Appears in gateway logs when an agent's HTTP timeout is shorter than model generation time — the client gave up mid-stream, but you may still be billed for generated tokens.
Fix checklist
- Raise client timeouts above worst-case generation time.
- Use streaming so data flows before any idle timeout fires.
- Check for users cancelling long requests.
Retry handler (TypeScript)
async function fetchWithRetry(url: string, init: RequestInit, maxRetries = 5) {
for (let attempt = 0; ; attempt++) {
const res = await fetch(url, init);
// 499 is retryable — back off and try again.
if (res.status !== 499 || 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
Related status codes
400 Bad Request
The server cannot process the request due to a client error — malformed JSON, invalid parameters, or schema violations..
401 UnauthorizedAuthentication is missing or invalid for this request..
402 Payment RequiredThe request requires payment — billing is not set up or a balance is exhausted..
403 ForbiddenThe server understood the request but refuses to authorize it — valid credentials, insufficient permission..