Engineering 4 min read Updated
HTTP status codes and what each one tells a client
In short
Pick the status code by asking who caused the problem, then which part of the request is wrong, using the meanings in RFC 9110 and MDN.
Clients read the status code before anything else in the response. It tells them whether the request succeeded, whether they need to change something, or whether the server failed. Getting the code right helps browsers, caches, monitoring and API clients react correctly. When in doubt, first decide whether the client or the server caused the problem.
Status codes fall into five classes
The first digit sets the class. MDN gives these ranges:
- 1xx: informational responses (100 to 199);
- 2xx: successful responses (200 to 299);
- 3xx: redirection messages (300 to 399);
- 4xx: client error responses (400 to 499);
- 5xx: server error responses (500 to 599).
RFC 9110 adds two points. The set of codes is extensible, and the reason phrases listed for each code are only recommendations. Software should therefore act on the number, not on the wording.
Client errors (4xx)
| Code | What the sources say |
|---|---|
| 400 Bad Request | The server cannot or will not process the request because of something it perceives as a client error |
| 401 Unauthorized | The request lacks valid credentials; RFC 9110 says the response must include a WWW-Authenticate header |
| 403 Forbidden | The server understood the request but refuses to fulfil it |
| 404 Not Found | The server did not find a current representation for the resource |
| 405 Method Not Allowed | The method is known to the server but is not supported by the target resource |
| 409 Conflict | The request conflicts with the current state of the resource, and the user may be able to resolve it |
| 422 Unprocessable Content | The request is well formed but cannot be followed because of semantic errors |
| 429 Too Many Requests | The client has sent too many requests in a given amount of time |
Authentication and permission are not interchangeable
The most common mix-up is between 401 and 403. Use 401 when the request has no valid credentials, and remember that RFC 9110 requires a WWW-Authenticate header with that response. Use 403 when the server has understood the request and refuses to carry it out.
Whether a removed page comes back decides the code. RFC 9110 says that 404 means the server found no current representation, and that 410 Gone is preferred over 404 when the condition is likely permanent. If you do not know whether a page will return, use 404. For how these codes look to search engines, read the article on 404, 410 and soft 404.
Working on something similar in your own product? A few honest sentences are enough – we read every enquiry and reply by email. Apply with your idea
Retry-After helps with rate limits
MDN describes 429 as a client error that indicates the client has sent too many requests in a given amount of time, a mechanism commonly called rate limiting. A Retry-After header may tell the client how long to wait. The example value is 3600 seconds, which is 60 minutes. Limits may apply to the whole server or to a single resource, and are typically based on the client’s IP address, or on the user when requests are authenticated. The principles are set out in the article on rate limiting and abuse protection.
Server errors (5xx)
RFC 9110 describes 500 Internal Server Error as the response to an unexpected condition that stopped the server from fulfilling the request. A 503 Service Unavailable response means the server cannot handle the request right now, typically because of temporary overload or scheduled maintenance. RFC 9110 allows it to carry a Retry-After header, so the client knows when to try again.
Keep the detail of a 500 in your logs rather than in the response. The article on API error responses shows how to structure what a client does receive.
Work out who caused the error, then pick the code
- First decide whether the client or the server caused the problem. That decides between the 4xx and 5xx classes.
- For a 4xx response, identify the exact part that is wrong: credentials, permissions, the resource, the method, the state or the request rate.
- Use 401 only for missing or invalid credentials, and 403 when the server has understood the request and refuses it.
- For a 503, add Retry-After when you know a sensible time to wait.
- Before you release the change, compare your choice with the table above.
The meanings above follow MDN and RFC 9110. Some APIs define their own error bodies and codes, so check their documentation before reusing these choices.
Common questions
- What is the difference between 401 and 403?
- A 401 means the request lacks valid credentials, and RFC 9110 says the response must include a WWW-Authenticate header. A 403 means the server understood the request but refuses to fulfil it.
- Should a deleted page return 404 or 410?
- RFC 9110 prefers 410 Gone over 404 when the condition is likely permanent. Use 404 when you do not know whether the page will return.
- Can a 500 response explain what went wrong?
- A 500 means the server met an unexpected condition. RFC 9457 warns that error details must be vetted for leakage, so keep internal diagnosis in your logs.
Sources
- HTTP response status codes, MDN Web Docs. Accessed 24 November 2026
- 429 Too Many Requests, MDN Web Docs. Accessed 24 November 2026
- HTTP Semantics, IETF (RFC 9110). Accessed 24 November 2026
Further reading
-
API error responses that clients can act on
Return the status code, then a problem details body with a stable type, a short title, a detail for this request and no internal information.
-
Rate limiting that protects forms and logins
Rate limiting caps how often a client may repeat an action, and a 429 response with Retry-After tells honest clients when to try again.
-
404, 410 and soft 404 errors
A removed page should return a real 404 or 410, a moved page a 301 redirect, and a soft 404 is an error message sent with a success code.
Have an idea that should exist? Or a working product that needs more customers, a new website or a complete rework? Bring us anything. Apply with your idea