HTTP Status Codes

Status codes are three-digit integers in the response status line. The first digit defines the class.

HTTP/1.1 404 Not Found
         ↑↑↑
         class = 4 (client error)
ClassRangeMeaning
1xx100–199Informational — request received, continue
2xx200–299Success — request understood and processed
3xx300–399Redirection — further action required
4xx400–499Client Error — bad request from the client
5xx500–599Server Error — server failed a valid request

1xx — Informational

CodeNameDescription
100ContinueServer received request headers; client should send the body. Used with Expect: 100-continue to avoid sending large bodies on auth failure.
101Switching ProtocolsServer is switching protocols per client request. Used to upgrade from HTTP/1.1 → WebSocket or HTTP/2.
103Early HintsServer sends preliminary response headers before the final response. Allows client to preload resources while server prepares the full response.

2xx — Success

CodeNameDescription
200OKStandard success. Body present. Returned for GET, POST, PUT, PATCH.
201CreatedResource successfully created. Location header should point to the new resource. Returned for POST/PUT.
202AcceptedRequest accepted for processing, but processing not complete. Used for async jobs. No body required.
204No ContentSuccess, no body. Common for DELETE and PUT responses where the client doesn’t need the updated resource.
206Partial ContentResponse contains a partial resource body. Used with Range requests for resumable downloads and video scrubbing.

3xx — Redirection

The client must take additional action to complete the request.

CodeNamePermanent?Method Preserved?Description
301Moved Permanently❌ (may change to GET)Resource permanently at new URI. Browsers and crawlers update bookmarks/indexes.
302Found❌ (may change to GET)Temporary redirect. Original URI should still be used for future requests.
303See Other❌ (always GET)Redirect after a POST to a GET resource. Prevents re-submission on refresh. POST → redirect → GET pattern.
304Not ModifiedResource not changed since If-Modified-Since or If-None-Match. Client uses cached version. No body returned.
307Temporary RedirectTemporary redirect; method and body preserved. Use instead of 302 if method must not change.
308Permanent RedirectPermanent redirect; method and body preserved. Use instead of 301 if method must not change.

301 vs 302 vs 307 vs 308

PermanentMethod Preserved
301
302
307
308
ℹ️

Use 308 when permanently moving a POST/PUT endpoint. Use 307 for temporary redirects that must preserve the HTTP method. When in doubt between 301 and 302, prefer 308 and 307 respectively — they are strictly correct.

ℹ️

304 returns no body. The browser uses its cached copy. Content-Type, Content-Length, and Content-Encoding headers are also omitted. Triggered by conditional request headers (If-None-Match, If-Modified-Since).

4xx — Client Error

The request is invalid or the client lacks permission.

CodeNameDescription
400Bad RequestMalformed syntax, invalid parameters, validation failure. Most common catch-all for bad input.
401UnauthorizedAuthentication required or failed. Response must include a WWW-Authenticate header describing the scheme.
403ForbiddenAuthenticated but not authorized. The server understands the request but refuses it.
404Not FoundResource does not exist at this URI. Also used intentionally to hide existence of unauthorized resources.
405Method Not AllowedHTTP method not supported on this resource. Response must include Allow header listing valid methods.
408Request TimeoutServer timed out waiting for the client to send the full request.
409ConflictState conflict, e.g., duplicate entry, concurrent write conflict, or version mismatch.
410GoneResource permanently deleted and will not return. Unlike 404, explicitly signals the resource existed.
411Length RequiredServer requires Content-Length header; client didn’t send one.
413Content Too LargeRequest body exceeds the server’s limit. Common for file upload endpoints.
415Unsupported Media TypeServer can’t process the request body’s Content-Type.
422Unprocessable EntityRequest is syntactically valid but semantically incorrect (e.g., failed business validation). Common in REST APIs.
429Too Many RequestsRate limit exceeded. Response should include Retry-After header.

401 vs 403

401403
Identity known?No (or failed auth)Yes
Can re-auth help?
Meaning“Who are you?”“I know you, but no.”

5xx — Server Error

The server failed to fulfill a valid request.

CodeNameDescription
500Internal Server ErrorGeneric server-side failure. Unhandled exception. Default error when nothing else fits.
501Not ImplementedServer doesn’t support the requested method. Different from 405 (method exists but not on this resource).
502Bad GatewayUpstream server returned an invalid response. Seen when a reverse proxy (Nginx, API Gateway) can’t reach the backend.
503Service UnavailableServer temporarily unable to handle requests — overloaded or in maintenance. Include Retry-After if possible.
504Gateway TimeoutUpstream server didn’t respond in time. Seen at load balancers and API gateways when backend is slow/unresponsive.
507Insufficient StorageServer can’t store the representation (WebDAV). Occasionally used for quota-exceeded scenarios.

500 vs 502 vs 503 vs 504

CodeWho failedWhen you see it
500Application codeUnhandled exception, crash
502Upstream serverInvalid/corrupt response from backend
503This serverOverloaded, in deploy/restart
504Upstream serverBackend too slow (timeout)

Quick Reference

CodeTypical API Use
200Successful GET, POST, PUT
201Resource created (POST)
204Delete succeeded / update with no body
206Partial file download, video range request
301Permanent domain or URL change
304Conditional GET cache hit
400Validation error, malformed JSON
401Missing or invalid token
403Valid token, wrong permissions
404Resource not found
409Duplicate record, optimistic lock conflict
422Semantic validation failure
429Rate limit hit
500Unhandled server exception
502Reverse proxy can’t reach backend
503Server overloaded or deploying
504Backend timed out