How to use the HTTP Status Codes
- Type a code in the search box. Digits match codes that start with them, so 40 lists 400 to 409.
- Or type a word, such as redirect, cache or timeout, to search names and descriptions.
- Use the class filter to show only informational, success, redirection, client error or server error codes.
- Read the "Defined in" column to find the RFC section with the exact rules.
The five classes
The first digit of a status code gives its class. 1xx codes are informational and precede the final response. 2xx means the request succeeded. 3xx means the client must take another step, usually following a redirect. 4xx means the request has a problem that looks like the client's fault. 5xx means the server failed to fulfil a request that appears valid.
Clients are expected to treat an unrecognised code by its class: an unknown 4xx is handled like 400, and an unknown 5xx like 500.
Choosing between similar codes
301 and 308 are both permanent redirects, but 308 requires the client to repeat the same method and body, while some clients change a POST to GET after a 301. The same difference separates the temporary redirects 302 and 307. Use 303 to send the client to a result page with GET after a POST.
401 means the request has no valid credentials, so the client can try again with them. 403 means the server understood who is asking and still refuses. Use 404 when nothing exists at the URL and 410 when it existed and was removed on purpose. Use 400 for a malformed request and 422 when the request is well formed but its content fails validation.
502, 503 and 504 all look like outages but differ: 502 is an invalid response from an upstream server, 503 is a server that cannot take the request now, and 504 is an upstream server that did not answer in time.
Registered and unregistered codes
This list follows the IANA HTTP Status Code Registry and RFC 9110. Some servers, CDNs and frameworks send extra codes of their own that are not in the registry; look those up in the documentation of that product.
Frequently asked questions
What is the difference between 401 and 403?
401 means the request has no valid authentication, and the response should say how to authenticate. 403 means the server knows what is being asked and refuses it, so logging in again will not change the answer unless the account gets more permission.
Should I use 301 or 302 for a redirect?
Use 301 (or 308) when the URL has moved for good, so clients and search engines switch to the new address. Use 302 (or 307) when the move is temporary. If the method must not change from POST to GET, pick 307 or 308.
What does 429 Too Many Requests mean?
The client has sent too many requests in a given time and is being rate limited. A Retry-After header, when present, says how long to wait.
Is 418 I'm a teapot a real status code?
It comes from an April Fools RFC. In the current registry 418 is marked (Unused), so it is reserved and not an active status.
What is the difference between 502 and 504?
Both come from a gateway or proxy. 502 means the upstream server sent back an invalid response. 504 means the upstream server did not respond in time.
Sources
Last reviewed