Contents

Web & Networking › HTTP

HTTP Status Codes

Three-digit codes grouped 1xx–5xx describing the result.

Also known as: status codes, HTTP response codes, HTTP errors, 404, 500

Every HTTP response starts with a three-digit status code saying how the request went. The first digit gives the family:

RangeMeaningWhose fault
1xxInformationalRarely seen directly
2xxSuccess
3xxRedirection: go elsewhere
4xxClient error: your request was wrongThe caller
5xxServer error: the server failedThe server

The ones to know

CodeNameWhen
200OKNormal success
201CreatedA resource was created (POST)
204No ContentSuccess with nothing to return (often DELETE)
301 / 302Moved Permanently / FoundRedirects; the Location header gives the new URL
304Not ModifiedUse your cached copy
400Bad RequestMalformed or invalid input
401UnauthorizedNot authenticated (401 vs 403)
403ForbiddenAuthenticated, but not allowed
404Not FoundNo such resource
409ConflictClashes with current state, such as a duplicate
422Unprocessable ContentWell-formed but fails validation (used by many APIs)
429Too Many RequestsRate-limited
500Internal Server ErrorA bug or crash on the server
502 / 503 / 504Bad Gateway / Service Unavailable / Gateway TimeoutA server behind a proxy failed, is overloaded, or is too slow

Why it matters

  • Clients decide what to do from the code: retry a 503, redirect to login on a 401, show a message on a 400, but not retry a 400.
  • Use the right code in your API. Returning 200 with {"error": "..."} hides failures from monitoring, caches and client libraries.
  • A 4xx vs 5xx split guides debugging: 4xx, look at the request; 5xx, look at server logs.

See 4xx and 5xx for more detail.