Web · Reference

HTTP Status Codes: The Complete Reference

Every standardised HTTP status code, what it means, and when servers should use it. Codes are grouped by class (1xx informational, 2xx success, 3xx redirection, 4xx client error, 5xx server error). The list reflects the IANA HTTP Status Code Registry as of June 2026.

The five classes at a glance

  • 1xx — Informational. Provisional, rarely seen by application code.
  • 2xx — Success. The request was received and acted on.
  • 3xx — Redirection. Further action needed (usually follow a Location header).
  • 4xx — Client error. The request is wrong; fixing the client will help.
  • 5xx — Server error. The request was fine; the server failed.

1xxInformational

CodeNameMeaningWhen to use it
100ContinueServer received headers, client should send the body.Used with Expect: 100-continue before uploading a large request body.
101Switching ProtocolsServer agrees to switch protocol (e.g. to WebSocket).Returned during a WebSocket or HTTP/2 upgrade handshake.
103Early HintsPreliminary headers (typically Link) so the browser can preload.Sent before the final response to start asset preloads in parallel.

2xxSuccess

CodeNameMeaningWhen to use it
200OKStandard success.Most successful GET responses.
201CreatedResource was created; Location header points to it.POST that creates a new entity.
202AcceptedRequest accepted for processing but not yet completed.Async jobs, queued background work.
204No ContentSuccess, no body to return.PUT/DELETE that has nothing to send back; preflight responses.
206Partial ContentRange request honoured.Video seeking, resumable downloads (Range: bytes=).

3xxRedirection

CodeNameMeaningWhen to use it
301Moved PermanentlyResource permanently at the new Location.HTTPS redirects, domain migrations, removing trailing slashes.
302FoundTemporary redirect, method may change.Legacy login flows; avoid for new APIs — use 307/308.
303See OtherRedirect with forced GET on the next request.POST-redirect-GET pattern after a form submission.
304Not ModifiedCached response is still valid.Conditional GET (If-None-Match, If-Modified-Since).
307Temporary RedirectTemporary, method preserved.Like 302 but the method is guaranteed to stay the same.
308Permanent RedirectPermanent, method preserved.Like 301 but POST stays POST.

4xxClient error

CodeNameMeaningWhen to use it
400Bad RequestMalformed request the server can't parse.Invalid JSON, missing required parameters, schema validation failure.
401UnauthorizedAuthentication required or invalid credentials.Missing/expired token. Includes WWW-Authenticate header.
403ForbiddenAuthenticated but not allowed.User logged in but lacks permission for this resource.
404Not FoundResource does not exist.Unknown URL, deleted record. Don't leak existence info via 403 vs 404.
405Method Not AllowedMethod not supported on this URL.POST to a read-only endpoint. Must return Allow header.
406Not AcceptableServer can't produce a format the client accepts.Content negotiation failure (Accept header mismatch).
408Request TimeoutClient took too long to send the request.Slow uploads, idle keep-alive connections.
409ConflictRequest conflicts with current state.Optimistic concurrency failure, duplicate resource creation.
410GoneResource permanently removed; no forwarding.Deleted accounts, sunsetted APIs. Helps search engines deindex.
411Length RequiredContent-Length header missing.Servers that refuse chunked uploads.
413Payload Too LargeRequest body exceeds limit.Upload bigger than max_body_size.
415Unsupported Media TypeBody's Content-Type is not accepted.Sending XML to a JSON-only endpoint.
418I'm a teapotRFC 2324 joke; legitimately used to reject bot traffic.Some sites return 418 instead of 403 to confuse scrapers.
422Unprocessable ContentSyntax is valid but semantically wrong.Validation errors after the body parsed correctly (Rails, FastAPI, Laravel).
423LockedResource is locked.WebDAV; some apps use it for tenant locks.
425Too EarlyServer unwilling to risk replaying request.HTTP/3 0-RTT replay protection.
428Precondition RequiredServer requires conditional requests.APIs that demand If-Match to prevent lost updates.
429Too Many RequestsRate limit hit.Include Retry-After header. Standard for API throttling.
451Unavailable For Legal ReasonsBlocked due to legal demand.DMCA takedowns, GDPR geo-restrictions, court orders.

5xxServer error

CodeNameMeaningWhen to use it
500Internal Server ErrorGeneric server-side failure.Unhandled exception. Log it, alert on it.
501Not ImplementedMethod not supported by the server at all.Server doesn't recognise the HTTP method (different from 405).
502Bad GatewayUpstream server returned an invalid response.Origin crashed or returned malformed data through a reverse proxy.
503Service UnavailableServer temporarily can't handle the request.Maintenance windows, overload. Include Retry-After.
504Gateway TimeoutUpstream didn't respond in time.Origin too slow, network issue between proxy and origin.
505HTTP Version Not SupportedServer doesn't support the request's HTTP version.Rare — client speaking HTTP/0.9 to a modern server.
507Insufficient StorageServer out of disk for the operation.Upload endpoints when the disk is full.
511Network Authentication RequiredCaptive portal demanding login.Hotel and airport WiFi gateways.

Best-practice cheat sheet

  • Authentication missing → 401; authentication present but insufficient → 403.
  • Validation error after parsing → 422; malformed body that wouldn't parse → 400.
  • Permanent redirect that must preserve method → 308; legacy/website canonical → 301.
  • Rate limit hit → 429 with Retry-After.
  • Origin down behind a proxy → 502; upstream slow → 504; planned maintenance → 503 with Retry-After.
  • Deleted resource that should be deindexed → 410 beats 404.

Inspect them yourself

Frequently asked questions

What's the difference between 401 and 403?+

401 means 'I don't know who you are' — you need to authenticate. 403 means 'I know who you are, and you're not allowed'. Returning 403 for unauthenticated users leaks the existence of the resource; prefer 401 + WWW-Authenticate.

Should I use 301 or 308 for permanent redirects?+

Use 308 for APIs or anywhere the request method matters — 301 historically allowed clients to change POST to GET, while 308 guarantees the method is preserved. For plain HTTPS canonical redirects on a website, 301 is still universally supported and cached well.

When should an API return 204 vs 200?+

Return 204 when there is genuinely no body to send (a successful DELETE, a PUT that doesn't echo state). Return 200 with a body when the client benefits from the updated resource representation. Don't return 204 with a body — clients are allowed to drop it.

Is 422 just a fancy 400?+

Functionally similar, but the distinction is useful: 400 means 'I couldn't parse this' (malformed JSON, bad syntax), while 422 means 'I parsed it fine but the data doesn't make sense' (a negative age, a missing required field after parsing). Most modern frameworks (FastAPI, Laravel, Rails) return 422 for validation errors.

What status code should I use for rate limiting?+

429 Too Many Requests, with a Retry-After header (either seconds or an HTTP date). Some legacy services return 503; 429 is the modern, specific answer.

Why is 418 'I'm a teapot' in the spec?+

It started as an April Fools' joke in RFC 2324 (1998) for the Hyper Text Coffee Pot Control Protocol. It's been kept in the registry because too many sites and frameworks reference it, and several services use it as a polite way to reject obvious bot traffic.

Sources: RFC 9110 (HTTP Semantics), IANA HTTP Status Code Registry, RFC 6585 (Additional HTTP Status Codes).