On this page6 sections
ReferenceBeginner4-6 min reference

HTTP Status Codes

Status codes are the contract between client and server. Knowing the difference between 401 and 403, or 502 and 504, will save you from filing the wrong bug ticket.

1xx Informational

The request was received and the server is continuing to process it. Rarely surfaces in test assertions — most clients handle these transparently.

CodeNameWhen you'll see it
100ContinueClient sent Expect: 100-continue and may now send the body
101Switching ProtocolsServer agreeing to upgrade (e.g. WebSocket handshake)
102ProcessingWebDAV — request still being processed
103Early HintsServer preloading resources before final response

2xx Success

The request succeeded.

CodeNameTest for it when...
200OKGeneric success — GET returns a body, etc.
201CreatedPOST that creates a resource (/users, /orders)
202AcceptedAsync operation queued (jobs, exports)
203Non-Authoritative InformationResponse was modified by a proxy
204No ContentDELETE / PUT with no body to return
205Reset ContentForm should be cleared after submit
206Partial ContentRange requests (video streaming, resumable downloads)

3xx Redirection

Further action needed to complete the request.

CodeNameNotes
300Multiple ChoicesSeveral representations available
301Moved PermanentlyURL has changed for good — clients cache the new one
302FoundTemporary redirect (legacy — most APIs now use 307)
303See OtherUsed after POST to redirect to a GET (PRG pattern)
304Not ModifiedCached response is still valid
307Temporary RedirectLike 302 but preserves the HTTP method
308Permanent RedirectLike 301 but preserves the HTTP method

4xx Client Error

The request was malformed or unauthorised. Most regression tests live here.

CodeNameTest for it when...
400Bad RequestBody fails validation, missing required field, malformed JSON
401UnauthorizedNo credentials, expired token, invalid signature
402Payment RequiredReserved — used by some SaaS billing flows
403ForbiddenAuthenticated but lacks permission for this resource
404Not FoundResource doesn't exist (or is hidden from this user)
405Method Not AllowedPOST to an endpoint that only accepts GET
406Not AcceptableServer can't produce content matching Accept header
408Request TimeoutClient took too long to send the request
409ConflictDuplicate key, optimistic-locking failure
410GoneResource permanently removed (different from 404)
411Length RequiredMissing Content-Length header
412Precondition FailedIf-Match / If-Unmodified-Since failed
413Payload Too LargeFile upload exceeds server limit
414URI Too LongQuery string blew past server limit
415Unsupported Media TypeContent-Type the endpoint won't accept
416Range Not SatisfiableRange request beyond resource length
417Expectation FailedExpect header couldn't be met
418I'm a teapotRFC 2324 — easter egg, not for serious use
422Unprocessable EntityBody parses fine but is semantically invalid
423LockedWebDAV — resource is locked
425Too EarlyServer unwilling to process replayed request
428Precondition RequiredServer requires conditional headers
429Too Many RequestsRate limited — check Retry-After
431Request Header Fields Too LargeHeaders blew past server limit
451Unavailable For Legal ReasonsCensored or geo-blocked

401 vs 403 — the rule of thumb

  • 401 Unauthorized = "I don't know who you are." Caller needs to authenticate.
  • 403 Forbidden = "I know who you are, and you can't do this."

5xx Server Error

The server failed to fulfil a valid request. These should always trigger an alert in production.

CodeNameWhat's happening
500Internal Server ErrorCatch-all for unhandled exceptions
501Not ImplementedHTTP method or feature not supported
502Bad GatewayUpstream server returned an invalid response
503Service UnavailableOverloaded or in maintenance — usually transient
504Gateway TimeoutUpstream server took too long
505HTTP Version Not SupportedServer won't speak the requested HTTP version
507Insufficient StorageWebDAV — server out of space
508Loop DetectedWebDAV — infinite loop in PROPFIND
511Network Authentication RequiredCaptive portal / paywall

502 vs 503 vs 504 — the rule of thumb

  • 502 Bad Gateway = upstream replied, but with garbage.
  • 503 Service Unavailable = server is up but can't handle the request right now (overloaded, maintenance).
  • 504 Gateway Timeout = upstream didn't reply in time.

Common test assertions

// Cypress
cy.request('/api/users/999').its('status').should('eq', 404);
 
// Playwright
const response = await request.post('/api/login', { data: { email, password: 'wrong' } });
expect(response.status()).toBe(401);
 
// REST Assured (Java)
given().get('/api/admin/users').then().statusCode(403);