Orofold Labs

Launching soon

Notes Get in touch

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)

CodeWhat the sources say
400 Bad RequestThe server cannot or will not process the request because of something it perceives as a client error
401 UnauthorizedThe request lacks valid credentials; RFC 9110 says the response must include a WWW-Authenticate header
403 ForbiddenThe server understood the request but refuses to fulfil it
404 Not FoundThe server did not find a current representation for the resource
405 Method Not AllowedThe method is known to the server but is not supported by the target resource
409 ConflictThe request conflicts with the current state of the resource, and the user may be able to resolve it
422 Unprocessable ContentThe request is well formed but cannot be followed because of semantic errors
429 Too Many RequestsThe 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

  1. First decide whether the client or the server caused the problem. That decides between the 4xx and 5xx classes.
  2. For a 4xx response, identify the exact part that is wrong: credentials, permissions, the resource, the method, the state or the request rate.
  3. Use 401 only for missing or invalid credentials, and 403 when the server has understood the request and refuses it.
  4. For a 503, add Retry-After when you know a sensible time to wait.
  5. 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.

Sources and limits

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

  1. HTTP response status codes, MDN Web Docs. Accessed 24 November 2026
  2. 429 Too Many Requests, MDN Web Docs. Accessed 24 November 2026
  3. HTTP Semantics, IETF (RFC 9110). Accessed 24 November 2026

Further reading

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

All notes