Skip to content

HTTP Status Codes

Every HTTP response comes with a 3-digit status code that tells the client what happened.

Think of it like order statuses at a restaurant:

  • 1xx — “We’re looking at your order” (informational)
  • 2xx — “Here’s your food!” (success)
  • 3xx — “Your table moved, go over there” (redirection)
  • 4xx — “That item isn’t on the menu” (client error)
  • 5xx — “The kitchen is on fire” (server error)

flowchart TB
Start[Response Received] --> Category{What type?}
Category -->|"1xx<br/>Informational"| Info["WebSocket upgrade,<br/>Continue sending"]
Category -->|"2xx<br/>Success"| Success{What happened?}
Success -->|New data| Created[201 Created]
Success -->|Data returned| OK[200 OK]
Success -->|No data| NoContent[204 No Content]
Category -->|"3xx<br/>Redirection"| Redirect{What kind?}
Redirect -->|Permanent| Moved[301 Moved Permanently]
Redirect -->|Temporary| Found[302 Found]
Redirect -->|Use cache| NotMod[304 Not Modified]
Category -->|"4xx<br/>Client Error"| ClientError{What's wrong?}
ClientError -->|Bad format| BadReq[400 Bad Request]
ClientError -->|Not logged in| Unauth[401 Unauthorized]
ClientError -->|No permission| Forbid[403 Forbidden]
ClientError -->|Doesn't exist| NotFound[404 Not Found]
ClientError -->|Too fast| RateLimit[429 Too Many Requests]
Category -->|"5xx<br/>Server Error"| ServerError{What's wrong?}
ServerError -->|Generic| ISE[500 Internal Server Error]
ServerError -->|Bad upstream| BadGW[502 Bad Gateway]
ServerError -->|Overloaded| Unavail[503 Service Unavailable]
ServerError -->|Upstream timeout| GWTimeout[504 Gateway Timeout]
style Start fill:#7c3aed,color:#fff
style OK fill:#10b981,color:#fff
style Created fill:#10b981,color:#fff
style NoContent fill:#10b981,color:#fff
style NotFound fill:#ef4444,color:#fff
style ISE fill:#ef4444,color:#fff
style RateLimit fill:#f59e0b,color:#fff

CodeNameWhat it means
200OKEverything worked! The response contains the data
201CreatedA new resource was created (POST request)
202AcceptedRequest accepted but processing is not complete
204No ContentSuccess, but no data to return (DELETE request)
HTTP/1.1 200 OK
Content-Type: application/json
{"user": "Alice", "email": "alice@example.com"}

CodeNameWhat it means
301Moved PermanentlyThe resource has a new URL (bookmark the new one)
302Found (temporary)Temporarily at a different URL
304Not ModifiedUse your cached version (no need to re-download)
HTTP/1.1 301 Moved Permanently
Location: https://www.example.com/new-page

Result: The browser automatically follows the redirect to the new URL.


CodeNameWhat it means
400Bad RequestThe server couldn’t understand your request (malformed)
401UnauthorizedYou need to log in first
403ForbiddenYou’re logged in but don’t have permission
404Not FoundThe resource doesn’t exist (most famous one!)
405Method Not AllowedWrong HTTP method (e.g., POST when only GET is allowed)
408Request TimeoutThe server gave up waiting for your request
409ConflictConflict with current state (e.g., duplicate entry)
422Unprocessable EntityRequest is valid but semantically wrong (validation error)
429Too Many RequestsYou’re being rate-limited — slow down!
HTTP/1.1 404 Not Found
Content-Type: text/html
<h1>Page not found</h1>

💥 5xx — Server Error (Not Your Fault)

Section titled “💥 5xx — Server Error (Not Your Fault)”
CodeNameWhat it means
500Internal Server ErrorSomething went wrong on the server (generic)
502Bad GatewayServer got an invalid response from an upstream server
503Service UnavailableServer is overloaded or under maintenance
504Gateway TimeoutUpstream server didn’t respond in time
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
{"error": "Something went wrong"}

CodeMeaningWhat to do
200✅ OKEverything’s fine
201✅ CreatedResource was created
301🔀 Moved permanentlyUpdate your bookmarks
400❌ Bad requestFix your request format
401❌ UnauthorizedLog in or provide credentials
403❌ ForbiddenYou don’t have access
404❌ Not foundThe URL is wrong
429❌ Too many requestsWait before retrying
500💥 Server errorServer issue — try again later
503💥 Service unavailableServer is down

  • 2xx = Success (200 OK, 201 Created)
  • 3xx = Redirect (301 moved, 304 use cache)
  • 4xx = Client error — you did something wrong (404 Not Found)
  • 5xx = Server error — server has a problem (500 Internal Server Error)
  • 404 is the most famous — the page doesn’t exist
  • Always check the status code when debugging API calls