- What are the five HTTP status code categories?
- RFC 9110 defines five categories by the leading digit: 1xx (informational — request received, processing continues), 2xx (success — request was understood and accepted), 3xx (redirection — further action is needed to complete), 4xx (client error — the request is malformed or unauthorized), and 5xx (server error — the server failed to fulfill a valid request). The lookup tool color-codes each category so you can scan a list of unfamiliar codes and immediately know whether the problem is on the client or the server side.
- What's the difference between 401 Unauthorized and 403 Forbidden?
- 401 means the client hasn't authenticated — no credentials, expired token, or invalid login. The response should include a WWW-Authenticate header, and re-authenticating could fix it. 403 means the client IS authenticated but doesn't have permission for this resource. Re-logging in won't help; the user simply isn't allowed. The historical name 'Unauthorized' for 401 is misleading — 'Unauthenticated' is what it actually means.
- When should I use 301 vs 302 vs 307 vs 308?
- 301 Moved Permanently and 308 Permanent Redirect both signal a permanent move and are aggressively cached. The difference: 308 preserves the request method (a POST stays a POST on the new URL), while 301 may downgrade POST to GET on some old clients. 302 Found and 307 Temporary Redirect are temporary; 307 preserves the method, 302 historically does not. The modern rule: use 308 for permanent method-preserving moves, 307 for temporary ones, 301 for permanent GET-only moves (most common case), and 303 See Other after a POST when you want the client to fetch the result via GET (the Post/Redirect/Get pattern).
- What does 418 'I'm a teapot' mean?
- 418 is an April Fools' joke from RFC 2324 (Hyper Text Coffee Pot Control Protocol, 1998). Any attempt to brew coffee with a teapot should return this code. It became famous enough that Cloudflare uses it for certain bot-blocking responses and Google maintains a /teapot endpoint. The IETF tried to remove it from the HTTP semantics draft in 2017 and got such an outraged response (savetheteapot.com) that it was reinstated. Not for production error handling — clients won't know what to do with it.
- What's the difference between 502, 503, and 504?
- All three are 5xx server errors that look similar in browser screenshots, but they mean different things. 502 Bad Gateway: the proxy got an invalid response from the upstream — the app server crashed, returned malformed bytes, or dropped the connection. 503 Service Unavailable: the server is temporarily overloaded, in maintenance, or starting up — the response should include a Retry-After header. 504 Gateway Timeout: the proxy got NO response from the upstream within the timeout window — the upstream is slow, not broken. Roughly: 502 = bad response, 503 = no capacity, 504 = no response in time.
- What's 429 and how should clients handle it?
- 429 Too Many Requests means the client has been rate-limited. The server should include a Retry-After header (in seconds or as a date) telling the client when it's safe to try again. Smart clients honor that header; less smart ones fall back to exponential backoff with jitter. Common API patterns: GitHub uses 429 plus X-RateLimit-Remaining headers; Stripe uses 429 plus structured error details. Don't use 503 for rate limits — 429 is the specific code, and clients increasingly know how to handle it correctly.
- Are 499 and 520-524 official HTTP status codes?
- No. 499 Client Closed Request is an nginx-specific code logged when the client closes the connection before the server finishes sending the response — common in access logs from users who navigated away from a slow page. 520-524 are Cloudflare-specific codes for origin-side problems (520 = unknown error, 521 = origin down, 522 = TCP timeout, 523 = origin unreachable, 524 = origin took longer than 100 seconds). They're not in any RFC, but you'll see them in production, so the lookup tool covers them.
- When should I return 400 vs 422 for invalid input?
- Use 400 Bad Request for syntactic problems — the JSON didn't parse, a required field is missing, a type was wrong. Use 422 Unprocessable Content for semantic problems — the syntax is valid but the data fails business rules (end_date before start_date, email already exists, password too weak). The line isn't always crisp, but the convention is widely used by REST and GraphQL APIs: Rails, Stripe, and GitHub all reach for 422 for validation errors that aren't shape errors. Pick one convention per API and document it.
- What is 451 Unavailable For Legal Reasons?
- 451 was added in RFC 7725 (2016) for content that has been removed due to legal demands — DMCA takedowns, GDPR right-to-be-forgotten requests, court orders, government censorship. The code number is a deliberate reference to Ray Bradbury's Fahrenheit 451. The RFC encourages including the reason in the response so the user understands why. Many sites use 403 Forbidden in these situations, but 451 is more honest about the cause and lets crawlers tag the URL appropriately.
- What does 304 Not Modified mean?
- 304 is the response to a conditional request (one that includes If-None-Match or If-Modified-Since) when the cached copy the client has is still fresh. The response body must be empty — the server is saying 'your cache is fine, keep using it.' It saves bandwidth on revalidation. The 304 response should echo back the same ETag or Last-Modified headers the 200 response would have, so caches can refresh their freshness window without re-downloading the content.