Status codes and reason phrases

In the HTTP response that is sent to a client, the status code, which is a three-digit number, is accompanied by a reason phrase (also known as status text) that summarizes the meaning of the code. Along with the HTTP version of the response, these items are placed in the first line of the response, which is therefore known as the status line.

The status codes are classified by number range, with each class of codes having the same basic meaning.
  • The range 100-199 is classed as Informational.
  • 200-299 is Successful.
  • 300-399 is Redirection.
  • 400-499 is Client error.
  • 500-599 is Server error.
When describing a range as a whole, it may be named as "1xx", "2xx", and so on. The HTTP protocol specifications do not define any status codes of 600 or greater.

Only a few status codes in each range are defined by the HTTP/1.0 and HTTP/1.1 specifications. The HTTP/1.1 specification includes more status codes than the HTTP/1.0 specification.

The reason phrases defined in the HTTP specifications (for example, "Not Found" or "Bad Request") are recommended but optional. The HTTP/1.1 specification says that the reason phrases for each status code may be replaced by local equivalents.

The 200 (OK) status code is used for a normal response that provides the full resource requested by the web client. Most other status codes are used in situations where there is an error that prevents fulfilment of the request, or where the client needs to do something else in order to complete its request successfully, such as following a redirection URL, or amending the request so that it is acceptable to the server.

The HTTP headers for the response, or the response body, or both, may provide further instructions and information for the client. The HTTP specifications include requirements and suggestions for the content of responses with each status code. The requirements specify:
  • Any HTTP headers that must, or may, be used on the response. For example, if you use the status code 405 (Method not allowed), you must use the Allow header to state the methods which are allowed.
  • Whether or not a response body should be used. For example, message bodies are not allowed with status codes 204, 205, and 304.
  • If a response body is used, what information it can provide. For example, message bodies for a redirection can provide a hyperlink for the redirection URL.

For full information about the meaning and correct use of status codes, you should consult the HTTP specification to which you are working. See The HTTP protocol for more information about the HTTP specifications.