Skip to main content

HTTP Status Codes I Actually Confuse

Not a complete list — MDN has that. These are the ones I keep second-guessing.


The Ones I Mix Up

200 vs 201 vs 204

CodeMeaningWhen I use it
200 OKRequest succeeded, body contains resultGET, successful PUT/PATCH
201 CreatedResource was created, Location header points to new resourcePOST that creates a record
204 No ContentSuccess, no bodyDELETE, or PUT where response body isn't needed

Mistake I used to make: Returning 200 for a DELETE. Should be 204 — there's nothing to return.


400 vs 401 vs 403

CodeMeaningWhen I use it
400 Bad RequestClient sent invalid inputMissing required field, bad JSON, failed validation
401 UnauthorizedNot authenticatedNo token, expired token, invalid token
403 ForbiddenAuthenticated but not authorizedToken is valid but user lacks permission

Naming gotcha: 401 Unauthorized is actually about authentication, not authorization. 403 Forbidden is authorization. The names are backwards from the concepts.


404 vs 410

CodeMeaning
404 Not FoundResource doesn't exist (or you're hiding that it does)
410 GoneResource existed but was permanently deleted

I use 410 when a user deletes their account — soft redirect to a "this account was removed" page. Otherwise 404.


422 vs 400

CodeMeaning
400 Bad RequestRequest is malformed (can't parse it)
422 Unprocessable EntityRequest is valid syntax but fails business logic validation

Example: 400 → invalid JSON body. 422 → JSON is fine, but email field is not a valid email format.


429 — Rate Limited

429 Too Many Requests — always include Retry-After header so clients know when to retry.


500 vs 502 vs 503 vs 504

CodeMeaningTypical cause
500 Internal Server ErrorUnhandled exception in your codeBug, uncaught throw
502 Bad GatewayUpstream server returned invalid responseDownstream service crashed
503 Service UnavailableServer is intentionally unavailableMaintenance, overload
504 Gateway TimeoutUpstream server didn't respond in timeDownstream service too slow

Rule: If the error is in my service, it's 500. If it's a dependency that failed, it's 502 or 504.