HTTP Status Codes Cheat Sheet: What Each Code Means and When to Send It
Checked against HTTP status codes and headers RFC 9110 and RFC 9111 (June 2022), RFC 6585; MDN pages read 28 Nov 2026 on 28 November 2026. Each section links to the official docs it was checked against.
This sheet is for people building or debugging HTTP APIs who need to pick the right status code and know which header has to come with it. Meanings follow RFC 9110, which replaced RFC 7231 in June 2022, and RFC 6585 for 428, 429, 431 and 511. Header advice comes from RFC 9111 and the MDN reference as it read on 28 November 2026.
When to use what
Pick by who has to act. If the client can fix the request, send a 4xx; if the problem is on your side, send a 5xx. That split matters more than the exact number, because retry logic, monitoring and CDNs all key off the first digit.
Within 4xx, my rule is: 400 for a request you can't parse, 422 for one you parsed but whose values fail validation, 409 for a clash with current state (a duplicate email, a stale version). Send 401 when credentials are missing or bad, and 403 when you know who the caller is and the answer is still no. If revealing that a resource exists is itself a leak, 404 is allowed in place of 403.
For redirects, use 308 and 307 when the method and body must survive the hop, 301 and 302 for plain page moves, and 303 to send a browser to a result page after a POST. Use 429 with Retry-After for rate limits, and 503 with Retry-After for planned downtime; a client that sees 500 has no idea when to come back.
Check any live endpoint with our HTTP status tester, look a code up in the status code reference, and read HTTP status codes in API design for longer examples.
200 OKRequest worked and the body holds the result; the default for GET
201 CreatedA POST or PUT made a new resource; point at it with a Location header
202 AcceptedWork was queued but not done yet; return a link the client can poll
204 No ContentSuccess with no body, common for DELETE or a PUT that returns nothing
206 Partial ContentAnswer to a Range request carrying only the requested bytes, used for resumable downloads
RFC 9110 notes that clients have historically changed POST to GET when following 301 and 302. If the method must stay the same, 307 and 308 forbid that change.
301 Moved PermanentlyPage moved for good; browsers and search engines update to the new URL
302 FoundTemporary move where a POST may turn into a GET on the next request
303 See OtherAfter a form POST, send the browser to a result page fetched with GET
304 Not ModifiedThe cached copy is still good; reply to If-None-Match or If-Modified-Since with no body
307 Temporary RedirectTemporary move that keeps the original method and body
308 Permanent RedirectPermanent move that keeps the method, the safe choice for moved API endpoints
400 Bad RequestMalformed syntax the server can't parse, such as broken JSON
401 UnauthorizedNo valid credentials; must include a WWW-Authenticate challenge
403 ForbiddenCaller is known but not allowed; logging in again won't help
404 Not FoundNothing at this URL, or you choose not to say whether something exists
405 Method Not AllowedMethod isn't supported on this URL; must list allowed ones in an Allow header
406 Not AcceptableCan't produce any format the Accept header asked for
409 ConflictRequest clashes with the resource's current state, such as a duplicate key
410 GoneResource was removed on purpose and won't come back
412 Precondition FailedAn If-Match or If-Unmodified-Since condition was false, so the write was refused
413 Content Too LargeRequest body is over the server's limit (formerly Payload Too Large)
415 Unsupported Media TypeBody sent in a Content-Type the endpoint doesn't accept
422 Unprocessable ContentBody parsed fine but failed validation, such as a missing required field
428 Precondition RequiredServer insists on a conditional request to stop lost updates
429 Too Many RequestsClient hit a rate limit; may include Retry-After saying when to try again
431 Request Header Fields Too LargeHeaders too big overall or one header too big, often an oversized cookie
511 Network Authentication RequiredA captive portal wants the user to log in to the network first
500 Internal Server ErrorUnhandled failure on the server; log it and don't leak a stack trace
501 Not ImplementedServer doesn't support the method at all, on any resource
502 Bad GatewayA proxy got an invalid response from the upstream it forwarded to
503 Service UnavailableOverloaded or down for maintenance; add Retry-After if you know when it's back
504 Gateway TimeoutA proxy gave up waiting for the upstream to answer
no-cache does not mean do not cache. It lets a cache store the response but forces a check with the server before each reuse. Use no-store when the response must never be written anywhere.
Cache-Control: public, max-age=31536000, immutableCache a hashed static asset for a year and skip revalidation on reload
Cache-Control: private, no-cachePer-user page: browser may store it but must revalidate before reuse
Cache-Control: no-storeNever store the response, for pages with tokens or personal data
Cache-Control: max-age=600, stale-while-revalidate=86400Serve a stale copy for up to a day while refreshing it in the background
ETag / If-None-MatchValidator pair that lets the server answer 304 instead of resending the body
Location: /orders/42Target of a 3xx redirect, or the new resource's URL on a 201
Retry-After: 120Seconds (or an HTTP date) to wait before retrying a 429 or 503
Content-Security-Policy: default-src 'self'Limit where scripts and other content may load from; MDN's replacement for X-XSS-Protection
X-XSS-ProtectionDeprecated, non-standard browser XSS filter header; don't add it to new sites
Expect-CTDeprecated Certificate Transparency opt-in that Chromium dropped support for starting in version 107
Access-Control-Allow-Origin: https://app.example.comLet one origin's browser JavaScript read the response
Worked example: Make a GET endpoint return 304 instead of resending the body
Most APIs send the full body on every poll. With an ETag, a client can ask whether anything changed and get an empty 304 instead. httpbin's /etag endpoint shows the exchange.
First request, no validator yet. Note the ETag the server hands back:
curl -s -D - -o /dev/null https://httpbin.org/etag/abc | grep -iE '^HTTP|^etag'
The second request sends that value back in If-None-Match:
curl -s -o /dev/null -w '%{http_code}\n' -H 'If-None-Match: "abc"' https://httpbin.org/etag/abc
304
The 304 tells the client its copy is current, so it reuses what it has and no body crosses the wire. On your own server, compute the ETag from the resource version or a hash of the body, compare it with If-None-Match, and return 304 with the same ETag and Cache-Control headers you would send on a 200. For writes, flip it around: require If-Match on PUT and answer 412 when the tag is stale, so two editors can't silently overwrite each other. Our CORS header builder is worth a look if a browser client needs to read the ETag header, since cross-origin scripts only see it when you list it in Access-Control-Expose-Headers. The guide to HTTP caching headers goes further.
Common mistakes
Returning 200 with an error message in the JSON body.
Clients, proxies and monitoring read the status line, not your body. Send the matching 4xx or 5xx and keep the error details in the body as well.
Sending 401 for a logged-in user who lacks permission.
401 means authenticate and try again, and it requires a WWW-Authenticate header. A known caller without access should get 403.
Moving a POST endpoint with a 301 or 302 and losing the request body.
Clients may switch to GET on those codes. Use 308 for a permanent move or 307 for a temporary one so the method and body are kept.
Setting
Cache-Control: no-cacheon a page with account details, thinking nothing will be stored.no-cachestill allows storage. Useno-storefor sensitive responses, andprivateso shared caches never keep them.Answering a rate-limited client with 503 or 500 and no hint about when to come back.
Use 429 with a
Retry-Afterheader. Good clients, including curl with--retry, wait the time you give them.Still shipping
X-XSS-Protection: 1; mode=blockandExpect-CTbecause an old checklist said so.Both are deprecated. Put the effort into a strict Content-Security-Policy and check the result with our security headers analyzer.
Related cheat sheets
Sources
- https://www.rfc-editor.org/rfc/rfc9110.html
- https://www.rfc-editor.org/rfc/rfc6585.html
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-XSS-Protection
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Expect-CT
How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.