HTTP status errors: handling 4xx and 5xx responses
A status error means the HTTP round trip worked — connection, TLS, request, response all succeeded — and the server used the status code to tell you something. Whether your client throws for it (axios rejects outside 2xx by default; fetch does not) is library policy, not protocol.
Whose bug is it?
400 Bad Request | Yours: malformed body, wrong content type, failed validation. Read the response body — most APIs say exactly which field. |
401 / 403 | Yours: missing/expired credentials (401) or valid credentials without permission (403). See the authentication guide. |
404 | Ambiguous: wrong URL or genuinely absent resource. APIs also use it to hide resources you can't access. |
409 / 422 | Yours, semantically: version conflict or well-formed-but-invalid input. |
429 Too Many Requests | You're being rate limited. Honor Retry-After; back off, don't hammer. |
500 | Theirs: an unhandled server error. Retrying rarely helps; report with a request ID if the API returns one. |
502 / 503 / 504 | Infrastructure: a proxy couldn't reach a healthy backend (502), the service is overloaded or deploying (503), or the upstream timed out (504). Transient by nature — the retryable family. |
Get the whole story
The status code is the headline; the response body and headers carry the actual
diagnosis. Log them on failure — an error handler that logs only "Request failed with status
code 400" discards the field-level detail the server already sent you. In axios that body is
error.response.data; in fetch you must read it before throwing your own error.
Retry policy in one paragraph
Retry 429 (respecting Retry-After), 503, and
502/504 for idempotent requests, with exponential backoff and a
cap. Never auto-retry 4xx — the request is wrong, and resending it is a louder way to be
wrong. Treat an unexpected 4xx in production as a bug report about your own request
construction, and an unexpected 5xx spike as the other side's incident: alert, degrade
gracefully, and stop sending non-essential traffic while it lasts.
Documented occurrences
349 analyzed errors across 116 libraries match this failure class. Each links to the thrown message, its source line, and documented fixes.
SillyTavern/SillyTavern
- Gateway Timeout
- Internal server error
- Internal Server Error
- Internal Server Error
- Internal server error.
- +41 more in SillyTavern
jackwener/OpenCLI
- coingecko derivatives returned HTTP 429 (rate limited)
- coingecko returned HTTP 429 (rate limited)
- coingecko returned HTTP 429 (rate limited)
- coingecko returned HTTP 429 (rate limited)
- coingecko returned HTTP 429 (rate limited)
- +21 more in OpenCLI
Mintplex-Labs/anything-llm
- Internal Server Error
- Internal Server Error
- Internal Server Error
- Internal Server Error
- Internal Server Error
- +19 more in anything-llm
overleaf/overleaf
- Internal server error.
- Internal Server Error (addNotification failure res.sendStatus(500))
- Internal Server Error (cannot bulk remove by key res.sendStatus(500))
- Internal Server Error (cannot count by key res.sendStatus(500))
- Internal Server Error (compile and download pdf failed res.sendStatus(500))
- +18 more in overleaf
langfuse/langfuse
- Internal server error
- Internal server error
- Internal server error
- Internal server error
- Internal Server Error
- +13 more in langfuse
infiniflow/ragflow
- GitHub credential appears to be invalid or expired (HTTP 401).
- Insufficient permissions to access Bitbucket workspace (HTTP 403).
- Insufficient permissions to access Confluence resources (HTTP 403).
- Invalid or expired Bitbucket credentials (HTTP 401).
- Invalid or expired Confluence credentials (HTTP 401).
- +6 more in ragflow
BerriAI/litellm
- Internal Server Error.
- Internal server error: {e}
- Internal Server Error ({e})
- Internal Server Error({e})
- Internal Server Error, " + str(e)
- +2 more in litellm
hcengineering/platform
- err.message (fallback: 'Internal Server Error')
- err.message?.length > 0 ? err.message : 'Internal Server Error'
- Internal Server Error
- Internal server error
- Internal server error
- +2 more in platform
kubernetes/kubernetes
- internal server error
- Internal Server Error: %q: %v
- Internal Server Error: %#v
- internal server error: %v
- internal server error: %v
- +1 more in kubernetes
langgenius/dify
- Internal Server Error
- Internal Server Error
- Internal Server Error
- Internal Server Error
- Internal Server Error
- +1 more in dify
…and 106 more libraries — search for your exact message.