Common HTTP status codes
Three digits that tell you, at a glance, exactly how a request went.
Every HTTP response opens with a three-digit status code grouped into five families: 1xx informational, 2xx success, 3xx redirection, 4xx client error, 5xx server error. The first digit tells you the category; the specific code tells you precisely what happened and who is at fault.
1xx — informational
The 1xx family is a set of provisional, interim responses that say 'received, keep going' before the real answer arrives. 100 Continue lets a client check that a large upload is welcome before sending the body, and 101 Switching Protocols is how an HTTP connection upgrades to WebSockets. You rarely see these directly because clients handle them under the hood.
2xx — success
The 2xx family means the request was received, understood and fulfilled. 200 OK is the everyday 'here is what you asked for'; 201 Created confirms a POST made a new resource and usually returns its location; 204 No Content signals success with deliberately no body, which is perfect for a DELETE or a silent save. All three say 'it worked' — they differ only in what comes back.
3xx — redirection
The 3xx family tells the client the resource lives elsewhere or has not changed. 301 is a permanent move (update your bookmarks and let search engines pass on ranking), 302 is a temporary redirect (keep using the original URL), and 304 Not Modified tells a client with a cached copy to reuse it instead of re-downloading. These codes power clean URLs, HTTPS upgrades and efficient caching.
4xx — client error
The 4xx family blames the request: the client asked for something malformed, forbidden or missing. 400 is a generic bad request, 401 means you are not authenticated, 403 means you are authenticated but not allowed, 404 means the resource does not exist, 409 signals a conflict (like an edit collision), and 429 means you have sent too many requests too fast. Fixing a 4xx means fixing the request.
5xx — server error
The 5xx family admits the server failed to fulfil an otherwise valid request. 500 is a catch-all internal error (an unhandled exception), 502 Bad Gateway means an upstream server returned garbage to a proxy, 503 Service Unavailable means the server is overloaded or down for maintenance, and 504 Gateway Timeout means an upstream server did not answer in time. These are the codes that page an on-call engineer.
Why status codes exist
Every HTTP response begins with a three-digit status code, and its whole purpose is to communicate the outcome of a request in a compact, machine-readable way. Without a standard code, every server would invent its own way of saying 'that worked' or 'that failed', and clients — browsers, mobile apps, other services — would have no reliable way to react. The status code is the agreed vocabulary that lets a client decide, without parsing the response body, whether to render the page, follow a redirect, retry, prompt for login, or surface an error.
The design is deliberately layered so you can understand a response at two levels of detail. The first digit classifies the response into one of five families, giving you an instant, coarse read on how things went. The full three-digit code then pins down the precise situation. This means even an unfamiliar code like 418 or 451 is partly legible — you know from the leading 4 that the client is being blamed — which makes the whole system extensible without breaking older clients.
Knowing these codes cold is one of the highest-value pieces of web knowledge there is: it is the shared language of debugging, appears constantly in logs and dev tools, and is a staple of interviews precisely because it reveals whether you actually understand the request/response model.
The five families
The first digit sorts every response into one of five buckets, and internalising just these five categories lets you triage almost any HTTP problem in seconds:
- 1xx — Informational. A provisional, interim reply meaning 'request received, still processing'. These are rare in day-to-day work and usually handled invisibly by the client.
- 2xx — Success. The request was received, understood and acted upon successfully. This is the happy path.
- 3xx — Redirection. The client must take an additional step — usually fetching a different URL — to complete the request. Browsers follow most of these automatically.
- 4xx — Client error. The request itself was wrong: malformed, unauthorised, or pointed at something that does not exist. The fix lives on the client side.
- 5xx — Server error. The request was fine, but the server failed to fulfil it. The fix lives on the server side.
That single split between 4xx and 5xx — *who is at fault, the caller or the server* — is the most important distinction of all, because it decides who has to change something to make the request succeed.
Success and redirection: 2xx and 3xx
The 2xx codes all mean success but differ in what accompanies them. 200 OK is the universal 'here is the resource you asked for' and covers the vast majority of successful GETs. 201 Created is the correct answer to a POST that made a new resource, and it conventionally includes a Location header pointing at the thing that was created. 204 No Content is success with a deliberately empty body — ideal for a DELETE, or a PUT where the client already knows the new state and does not need it echoed back.
The 3xx codes redirect or short-circuit. 301 Moved Permanently says the resource has a new home for good; browsers and search engines update their references and pass along SEO ranking, which is why it is the right tool for canonicalising URLs or forcing HTTPS. 302 Found is a *temporary* redirect — go here for now, but keep using the original address. The subtle but hugely important one is 304 Not Modified: when a client revalidates a cached resource (using If-None-Match or If-Modified-Since), a 304 tells it 'nothing changed, reuse your copy', sending no body at all. That tiny response saves enormous bandwidth and is a cornerstone of web caching.
Client errors: the 4xx family
The 4xx codes blame the request, and distinguishing them precisely is a mark of a careful API:
- 400 Bad Request — the request is malformed or fails validation; the server cannot even parse it as valid. It is the generic client-error fallback.
- 401 Unauthorized — really means *unauthenticated*: the server does not know who you are, and you should log in or provide credentials.
- 403 Forbidden — the server knows exactly who you are and is refusing anyway; you lack permission. The 401-vs-403 distinction is authentication versus authorization.
- 404 Not Found — there is no resource at that URL. The single most famous code on the web.
- 409 Conflict — the request clashes with the current state, such as two people editing the same record or creating a resource that already exists. Common in concurrent systems and optimistic-locking schemes.
- 429 Too Many Requests — you have hit a rate limit; slow down and retry after the interval, usually given in a
Retry-Afterheader.
Choosing the right 4xx is not pedantry: clients branch on these codes to decide whether to re-prompt for login, show 'not found', or back off and retry.
Server errors and how to use codes well
The 5xx codes are the server owning up to a failure on a request that was otherwise valid, and they are the ones that wake engineers up at night. 500 Internal Server Error is the catch-all for an unhandled exception or bug in the application. 502 Bad Gateway means a proxy or load balancer received an invalid response from an upstream server it was relaying to. 503 Service Unavailable means the server is temporarily unable to handle the request — overloaded, or intentionally down for maintenance — and is often paired with Retry-After. 504 Gateway Timeout is the timeout cousin of 502: a proxy waited for an upstream server and gave up before it answered.
The 502/503/504 trio is especially worth knowing in modern architectures, because they point the finger at *where* in a chain of proxies and services the failure happened, which is exactly what you need when debugging a distributed system.
In practice, using status codes well is a discipline: return the most specific accurate code, reserve 2xx strictly for genuine success (a common bug is returning 200 OK with an error message buried in the body, which lies to every client), and pair codes with a helpful body. Done right, the status code alone tells any client — human or machine — what happened and what to do next.
The first digit picks the family: 1xx info, 2xx success, 3xx redirect, 4xx client error, 5xx server error.
2xx: 200 OK, 201 Created (new resource), 204 No Content (success, empty body).
3xx: 301 permanent redirect, 302 temporary redirect, 304 Not Modified (use your cache).
4xx blames the client: 400 bad request, 401 unauthenticated, 403 forbidden, 404 not found, 409 conflict, 429 too many requests.
5xx blames the server: 500 internal error, 502 bad gateway, 503 unavailable, 504 gateway timeout.
Quick quiz
A user is logged in but tries to open an admin page they don't have rights to. Which code fits best?
Your API sits behind a proxy and an upstream server takes too long to respond. What does the client see?
The structure of a URL
Every address on the web is a packed little instruction set — decode it once and read it forever.
HTTP vs HTTPS
The single letter that turns an open postcard into a sealed, verified envelope.
What is a REST API
The architectural style that made the web's APIs feel like the web itself.
REST vs GraphQL
Two ways to shape an API — resources and endpoints, or one flexible query.