HTTP Status Codes Cheat Sheet
HTTP response status codes: 1xx–5xx classes, common codes, and when to use them.
HTTP status codes summarize the result of a request in three digits. The first digit identifies the class; the remaining digits provide a more specific meaning defined by the HTTP specification or an application convention.
Status classes
The class tells a client how broadly to interpret the response. A client should generally handle unknown codes according to their class and preserve response headers and body when useful.
| Class | Name | General meaning |
|---|---|---|
1xx | Informational | Request received; continue or provide interim information. |
2xx | Success | Request was successfully received and processed. |
3xx | Redirection | Further action or another location may be needed. |
4xx | Client error | The request cannot be fulfilled as sent. |
5xx | Server error | The server failed to fulfill an apparently valid request. |
1xx and 2xx
Informational responses are usually handled by protocol-aware clients. Success codes distinguish returned content, resource creation, and an intentionally empty response.
| Code | Meaning | Typical use |
|---|---|---|
100 | Continue | Client may send the request body. |
101 | Switching Protocols | Protocol upgrade accepted. |
200 | OK | Successful request with a representation or result. |
201 | Created | Resource created; Location may identify it. |
202 | Accepted | Accepted for asynchronous processing. |
204 | No Content | Successful request with no response body. |
HTTP/1.1 201 Created
Location: /users/42
Content-Type: application/json
{"id":42,"name":"Ada"}
3xx redirects and caching
Redirect codes tell a client to use another target or indicate that a cached representation remains valid. 301 and 308 are permanent; 302 and 307 are temporary. The 307 and 308 forms preserve the request method and body during the redirect.
| Code | Meaning |
|---|---|
301 | Permanently moved; clients may rewrite future requests. |
302 | Temporary redirect; historical clients may change method to GET. |
303 | See another resource, commonly after POST with a GET. |
304 | Not modified; use a valid cached representation. |
307 | Temporary redirect preserving method and body. |
308 | Permanent redirect preserving method and body. |
4xx client errors
A 4xx response means the server considers something about the request invalid, unauthorized, forbidden, missing, conflicting, or rate-limited. APIs should return a useful body when clients can correct the request.
| Code | Meaning |
|---|---|
400 | Bad Request: malformed syntax or invalid request framing. |
401 | Unauthorized: authentication is required or invalid. |
403 | Forbidden: identity is known or understood, but access is refused. |
404 | Not Found: target resource does not exist or is intentionally hidden. |
405 | Method Not Allowed: method is unsupported for the target. |
409 | Conflict with the current resource state. |
422 | Content understood but semantically invalid. |
429 | Too Many Requests: rate limit exceeded. |
401 concerns authentication; 403 concerns authorization. A 401 response commonly includes a WWW-Authenticate challenge, while 403 does not require the client to authenticate differently.
5xx server errors
5xx responses indicate a failure while processing a request the server could not complete. Gateways and proxies may generate some of these codes on behalf of an upstream service.
| Code | Meaning |
|---|---|
500 | Unexpected condition in the server. |
501 | Server does not support the requested functionality. |
502 | Gateway received an invalid upstream response. |
503 | Service temporarily unavailable, often overloaded or under maintenance. |
504 | Gateway timed out waiting for an upstream response. |
HTTP/1.1 503 Service Unavailable
Retry-After: 120
Content-Type: application/json
{"error":"temporarily unavailable"}
Client handling patterns
Treat status classes separately and respect headers such as Location, Retry-After, and caching validators. Retrying a request is safe only when the operation and server contract make it safe; use backoff for transient failures.
if (response.status === 429 || response.status >= 500) {
const retryAfter = response.headers.get("Retry-After");
// Apply bounded backoff according to the API contract.
} else if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}