ByteTips.

Guide

HTTP Status Codes Explained

The first digit tells you who is at fault: 2xx means success, 3xx means go elsewhere, 4xx means the client messed up, 5xx means the server did. The rest is detail.

October 24, 2026 · 7 min read · Shayan · JavaScript

Short answer: read the first digit. 1xx is informational, 2xx means the request succeeded, 3xx means redirect somewhere else, 4xx means the client sent something wrong, and 5xx means the server failed. That one digit answers the only question that matters first — whose fault is this, yours or the server's? — and the last two digits name the specific outcome.

2xx: success

  • 200 OK — the standard success response. GET returned the resource, POST/PUT did the thing.
  • 201 Created — a new resource was created, usually with a Location header pointing at it. The correct response to a successful POST that creates something.
  • 204 No Content — success with deliberately no body. Common for DELETE and for updates where the client already has the state.

3xx: redirection

  • 301 Moved Permanently — the resource lives at a new URL for good. Search engines transfer ranking to the new URL, so use 301 for permanent moves and 308 when the method and body must be preserved.
  • 302 Found (and 307 Temporary Redirect) — a temporary move. 302 historically lets clients change POST to GET on the redirect; 307 preserves the method. Use 307 when the distinction matters.
  • 304 Not Modified — not an error and not a redirect to follow: the client's cached copy is still fresh (from a conditional request with If-Modified-Since or If-None-Match), so the server sends no body. A 304 in your network tab usually means caching is working.

4xx: client error

  • 400 Bad Request — malformed syntax or invalid data: broken JSON, a missing required field, a value that fails validation. Your request, your fix.
  • 401 Unauthorized — despite the name, this means unauthenticated: credentials are missing or invalid. Log in or fix the token.
  • 403 Forbidden — authenticated but not allowed. A valid login that lacks permission gets 403, not 401 — mixing them up sends users to a login page they cannot pass.
  • 404 Not Found — no resource at this URL. Also the code servers return when they do not want to reveal whether a resource exists at all.
  • 409 Conflict — the request conflicts with current state: a duplicate unique value, an edit based on a stale version.
  • 422 Unprocessable Entity — the syntax is valid but the semantics are not: the JSON parses, but the email field is not an email. Validation errors belong here, not 400, in most modern APIs.
  • 429 Too Many Requests — rate limited. Back off, respect any Retry-After header, and retry later.

5xx: server error

  • 500 Internal Server Error — the server crashed handling your request. The bug is on their side; retrying the identical request rarely helps.
  • 502 Bad Gateway — a proxy or gateway got an invalid response from the upstream server. Common when the backend is down or restarting behind a load balancer.
  • 503 Service Unavailable — the server is temporarily unable to handle the request (overloaded or in maintenance). Unlike 500, retrying later is reasonable.
  • 504 Gateway Timeout — the proxy waited for the upstream and gave up. Slow backends and tight proxy timeouts produce this one.

How to read one in practice

Start with the class, then the code, then the body. A 4xx means change the request; a 5xx means wait or report it; a 3xx means follow the Location header. When debugging a fetch that 'doesn't work', open the network tab before the console: fetch only rejects on network failure, so an HTTP error still resolves — your code must check response.ok (true for 200–299, false otherwise) and handle the status explicitly, or a 404 will sail through as a successful promise carrying an error page.

Written by Shayan — Creator of Byte-Kit & ByteTips. Building private developer tools.

More JavaScript guides