Skip to content
Commitpedia
Log in Join & edit

HTTP status codes: the common ones and what to do

A quick reference to the HTTP status codes you will meet most often, what each one means, and the first thing to check when you see it.

Not checked by a trusted editor yet Last edited Outdated?

Edit history of HTTP status codes: the common ones and what to do: 1 recorded edit
Edit history · 1 edit
Type
Article
Edits
1
Editors
1
First issued
15 Oct 2026
Last edit
15 Oct 2026
Reading
2 min

Every HTTP response starts with a three-digit status code. The first digit tells you the category, so even an unfamiliar code gives you a hint: 2xx success, 3xx redirection, 4xx client error (fix the request), 5xx server error (fix or wait for the server).

2xx: it worked

  • 200 OK: success, the body has the result.
  • 201 Created: a new resource was made. Look for a Location header pointing to it.
  • 204 No Content: success with an empty body, common for DELETE and CORS preflight responses.

3xx: look somewhere else

  • 301 Moved Permanently and 308 Permanent Redirect: update your links. 308 guarantees the method and body are kept; with 301 clients may switch POST to GET.
  • 302 Found and 307 Temporary Redirect: temporary move. 307 keeps the method, 302 may not.
  • 304 Not Modified: your cached copy is still valid. Not an error.

curl does not follow redirects unless you add -L. Browsers and fetch() follow them automatically.

4xx: something is wrong with the request

  • 400 Bad Request: malformed input, often invalid JSON or a missing field. Read the response body; good APIs explain what failed.
  • 401 Unauthorized: you are not authenticated. The token or key is missing, expired, or wrong. Check the Authorization header.
  • 403 Forbidden: you are authenticated but not allowed. Check permissions, scopes, or roles; logging in again will not help.
  • 404 Not Found: wrong URL, wrong ID, or a resource the server prefers to hide from you.
  • 405 Method Not Allowed: the path exists but not for this method, for example POST to a read-only endpoint.
  • 409 Conflict: the request clashes with the current state, such as a duplicate username.
  • 413 Content Too Large (older name: Request Entity Too Large): the body is bigger than the server accepts.
  • 415 Unsupported Media Type: wrong or missing Content-Type.
  • 422 Unprocessable Content: the syntax is fine but the data fails validation.
  • 429 Too Many Requests: you hit a rate limit. Slow down and honor the Retry-After header if present.

5xx: the server failed

  • 500 Internal Server Error: an unhandled error in the application. Check server logs; retrying rarely helps.
  • 502 Bad Gateway: a proxy or load balancer got an invalid answer from the app behind it. Is the app running and listening on the expected port?
  • 503 Service Unavailable: overloaded or in maintenance. Retry later, ideally with backoff.
  • 504 Gateway Timeout: the app behind the proxy took too long. Look for slow queries or raise the proxy timeout carefully.

Checking a status code quickly

# Print only the status code
curl -s -o /dev/null -w '%{http_code}\n' https://example.com/

# Show the status line and headers, then the body
curl -i https://example.com/

In JavaScript, fetch() does not reject on 4xx or 5xx. It only rejects on network failures, so check response.ok (true for 200-299) or response.status yourself.

const response = await fetch("/api/items");
if (!response.ok) {
  throw new Error(`Request failed: ${response.status}`);
}
const items = await response.json();

When you build an API, pick the most specific code that fits and include a short JSON error message in the body. Clients and humans debugging them will both thank you. The full list lives in MDN’s status code reference and in RFC 9110.

See also

  • 0089 Fix: 413 Request Entity Too Large A server or proxy rejected your request because its body is bigger than the configured limit. Find which layer set the limit,… Intermediate · Fix · Any system, Linux Article Status codes · Web frameworks 15 Oct 2026
  • 0091 CSS selectors and specificity reference The selectors you will use every day, how the browser decides which rule wins when several match, and practical ways to keep… Intermediate · Reference · Browser Article References · Selectors & specificity 15 Oct 2026
  • 0263 Build a notes REST API with plain Node.js: CRUD, validation, status codes and CORS Write a small JSON API for notes using only Node.js built-ins: create, read, update and delete, input validation, correct HTTP status codes,… Intermediate · Tutorial · Any system Article Making requests · Node.js · Status codes 15 Oct 2026

Repos in the wild

History

Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.

  1. Commitpedia +3,288 chars

Report a problem

Something wrong, unsafe or copied? Tell the editors.
What is wrong?