HTTP status codes are numeric codes sent by a web server to a web browser to indicate the status of an HTTP request. These status codes serve to inform the client (web browser) about how the request was handled.
The main categories of HTTP status codes
There are five main categories of HTTP status codes, each conveying different information. Within the five main categories there is a wide range of codes, each of which likewise serves a different purpose.
1xx (Informational)
These codes indicate that the request was received by the server and that the process is continuing.
Examples:
Status code 100 (Continue) – This interim response indicates that the client should continue the request or ignore the response if the request is already complete.
Status code 102 (Processing) – This code indicates that the server has received the request and is processing it, but no response is available yet.
2xx (Success)
These codes indicate that the client’s request was successful and processed by the server.
Examples:
Status code 200 (OK) – The request was successful and the server delivers the expected data.
Status code 204 (No Content) – There is no content to send for this request, but the headers could be useful. The user agent may update its cached headers for this resource with the new ones.
3xx (Redirection)
These codes indicate that the client must take further action to complete the request, e.g. a redirect to another URL.
Examples:
Status code 301 (Moved Permanently) – The URL of the requested resource has been changed permanently. The new URL is given in the response.
Status code 303 (See Other) – The server sent this response to prompt the client to fetch the requested resource at another URI with a GET request.
4xx (Client Error)
These codes indicate that an error occurred on the client’s side, e.g. when the requested resource was not found or access was denied.
Examples:
Status code 404 (Not Found) – The requested resource was not found or does not exist on the server.
Status code 403 (Forbidden) – Access to the requested resource is prohibited and the client has no authorisation.
5xx (Server Error)
These codes indicate that an error occurred on the server’s side, e.g. when the server could not process the client’s request.
Examples:
Status code 500 (Internal Server Error) – A general server error occurred and the request could not be processed successfully.
Status code 502 (Bad Gateway) – This error response means that the server, while acting as a gateway to obtain a response needed to handle the request, received an invalid response.
Knowing the various HTTP status codes is important for developers to diagnose problems, fix errors and understand the communication between client and server on the web.