Introduction
HTTP (Hypertext Transfer Protocol) status codes are essential indicators of communication outcomes between clients (such as web browsers or mobile apps) and servers on the internet. They provide crucial information about the result of an HTTP request, enabling both clients and servers to understand and respond to different scenarios appropriately. In this article, we will delve into the significance and meaning of various HTTP status codes across different categories.
1. Informational Responses (1xx)
These status codes indicate provisional responses from the server, informing the client that the request is received and understood, and further action is required.
- 100 Continue: The server acknowledges the client's request headers and indicates that the client should proceed with the request.
- 101 Switching Protocols: The server confirms the client's request to switch protocols and indicates the change through the
Upgrade
header in the response.
- 102 Processing: The server has received and is processing the request but has not yet completed it (WebDAV; RFC 2518).
2. Successful Responses (2xx)
These status codes indicate that the client's request was successfully received, understood, and accepted.
- 200 OK: The request was successful, and the server returns the requested resource.
- 201 Created: The request has been fulfilled, and a new resource is created as a result.
- 202 Accepted: The request has been accepted for processing, but the processing has not been completed.
- 203 Non-Authoritative Information: The server is a transforming proxy and has received a 200 OK response from the origin server but is returning a modified version of the response.
- 204 No Content: The server successfully processed the request but does not need to return any content.
- 205 Reset Content: Tells the client to reset the document view, clearing the form data.
- 206 Partial Content: The server fulfills a partial GET request, indicating the requested range of data.
- 207 Multi-Status: Provides status for multiple independent operations (WebDAV; RFC 4918).
- 208 Already Reported: Used inside a DAV: propstat response element to avoid repeatedly enumerating the internal members of multiple bindings to the same collection (WebDAV; RFC 5842).
- 226 IM Used: The server has fulfilled a request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance (RFC 3229).
3. Redirection Messages (3xx)
These status codes indicate that the client needs to take additional action to complete the request.
- 300 Multiple Choices: Indicates multiple options for the resource from which the client can choose.
- 301 Moved Permanently: The requested resource has been permanently moved to a new URL.
- 302 Found: The requested resource temporarily resides at a different URL, and the client should use the new URL for subsequent requests.
- 303 See Other: The response to the request can be found under another URL using a GET method.
- 304 Not Modified: Indicates that the resource has not been modified since the version specified by the request headers.
- 305 Use Proxy: The requested resource is available only through a proxy, and the address is provided in the response.
- 307 Temporary Redirect: Similar to 302, indicating a temporary redirect, but the client should continue to use the original URL for future requests.
- 308 Permanent Redirect: The request and all future requests should be repeated using another URI (RFC 7538).
4. Client Error Responses (4xx)
These status codes indicate that there was an error on the client's side, such as malformed requests or authentication issues.
- 400 Bad Request: The server cannot process the request due to a client error, typically indicating malformed syntax.
- 401 Unauthorized: The client needs to authenticate itself to get the requested response.
- 402 Payment Required: Reserved for future use.
- 403 Forbidden: The server understood the request but refused to authorize it.
- 404 Not Found: The server cannot find the requested resource.
- 405 Method Not Allowed: The method specified in the request is not allowed for the resource identified by the request URI.
- 406 Not Acceptable: The server cannot generate a response that satisfies the constraints specified by the client in the request's "Accept" header field.
- 407 Proxy Authentication Required: Similar to 401, but it indicates that the client needs to authenticate itself with the proxy.
- 408 Request Timeout: The server did not receive a complete request message within the time that it was prepared to wait.
- 409 Conflict: Indicates that the request could not be completed due to a conflict with the current state of the resource.
- 410 Gone: Indicates that the requested resource is no longer available at the server, and no forwarding address is known.
- 411 Length Required: The server refuses to accept the request without a defined Content-Length.
- 412 Precondition Failed: One or more conditions given in the request header fields are evaluated as false when tested on the server.
- 413 Payload Too Large: The server refuses to process the request because the payload is larger than the server is willing or able to process.
- 414 URI Too Long: The server refuses to process the request because the URI is longer than the server is willing to interpret.
- 415 Unsupported Media Type: The server refuses to accept the request because the payload format is in an unsupported format.
- 416 Range Not Satisfiable: The client has asked for a portion of the file but the server cannot supply that portion.
- 417 Expectation Failed: The server cannot meet the requirements of the Expect request-header field.
- 418 I'm a teapot: The server refuses to brew coffee because it is, permanently, a teapot (RFC 2324).
- 421 Misdirected Request: The request was directed at a server that is not able to produce a response (RFC 7540).
- 422 Unprocessable Entity: The server understands the content type of the request entity but is unable to process the contained instructions (WebDAV; RFC 4918).
- 423 Locked: The resource that is being accessed is locked (WebDAV; RFC 4918).
- 424 Failed Dependency: The request failed because it depended on another request, and that request failed (WebDAV; RFC 4918).
- 425 Too Early: Indicates that the server is unwilling to risk processing a request that might be replayed (RFC 8470).
- 426 Upgrade Required: The client should switch to a different protocol, such as TLS/1.0 (RFC 2817).
- 428 Precondition Required: The origin server requires the request to be conditional (RFC 6585).
- 429 Too Many Requests: The user has sent too many requests in a given amount of time (RFC 6585).
- 431 Request Header Fields Too Large: The server is unwilling to process the request because its header fields are too large (RFC 6585).
- 451 Unavailable For Legal Reasons: The server is denying access to the resource as a consequence of a legal demand (RFC 7725).
5. Server Error Responses (5xx)
These status codes indicate that there was an error on the server's side, preventing it from fulfilling the request.
- 500 Internal Server Error: A generic error message indicating that something has gone wrong on the server's end.
- 501 Not Implemented: The server does not support the functionality required to fulfill the request.
- 502 Bad Gateway: The server, while acting as a gateway or proxy, received an invalid response from the upstream server.
- 503 Service Unavailable: The server is currently unable to handle the request due to temporary overloading or maintenance.
- 504 Gateway Timeout: The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server.
- 505 HTTP Version Not Supported: The server does not support the HTTP protocol version used in the request.
- 506 Variant Also Negotiates: Transparent content negotiation for the request results in a circular reference (RFC 2295).
- 507 Insufficient Storage: The server is unable to store the representation needed to complete the request (WebDAV; RFC 4918).
- 508 Loop Detected: The server detected an infinite loop while processing the request (WebDAV; RFC 5842).
- 510 Not Extended: Further extensions to the request are required for the server to fulfill it.
- 511 Network Authentication Required: The client needs to authenticate to gain network access (RFC 6585).
Understanding HTTP status codes is vital for web developers, system administrators, and anyone involved in building or maintaining web services. By interpreting these status codes correctly, developers can diagnose and troubleshoot issues effectively, leading to better user experiences and smoother interactions between clients and servers on the internet.