resources

HTTP Error Codes

resources/http-error-codes

HTTP Error Codes

Overview

This reference helps map common HTTP responses to the layer most likely responsible.


Why It Matters

The status code is often the fastest clue to where the failure happened.


Core Concepts

  • 2xx is success, but the UI can still be wrong.
  • 4xx usually means a request, auth, or validation problem.
  • 5xx usually means backend, proxy, or dependency trouble.

Mental Models

Start with the status code, then inspect the request, response body, and the boundary that owns the failure.


Best Practices

  • Check method, URL, status, and body together.
  • Verify redirects and caching.
  • Use logs when the code alone is not enough.

Common Mistakes

  • Assuming all 200 responses are good.
  • Treating all 500 errors as identical.
  • Ignoring redirects and cache behavior.

Trade-offs

Status codes are quick triage signals, not full diagnosis. They point you at the right layer.


Decision Framework

RangeUsual meaningFirst check
2xxSuccess, maybe broken UIState or rendering
3xxRedirectRouting, auth, cache
4xxClient issuePayload, auth, validation
5xxServer issueLogs, dependencies

Examples

CodeMeaningTypical frontend clue
200OKUI state or data mapping issue
401UnauthorizedAuth session or token issue
403ForbiddenPermission or role issue
404Not foundRoute or resource mismatch
422Validation failedForm or payload mismatch
429Rate limitedRetry or throttling issue
500Internal server errorBackend exception
502Bad gatewayProxy or upstream failure
503Service unavailableDeployment or maintenance
504Gateway timeoutSlow dependency or database

Checklists

  • Did I capture the exact status code?
  • Did I inspect the body and headers?
  • Do I know which layer owns the issue?

Senior Engineer Notes

Senior engineers use status codes to shrink the search space quickly. The code is the clue, not the conclusion.


Further Reading