HTTP status codes are three-digit numbers that are sent by a server in response to a client’s request to indicate the status of the requested resource. These codes are an important part of the HTTP protocol, which is the underlying protocol used for the World Wide Web. In this article you will know a complete guide and list of HTTP Status Codes.
Each HTTP status code indicates a different type of response to the client’s request. For example, a status code of 200 indicates that the request was successful, while a status code of 404 indicates that the requested resource was not found on the server.
HTTP status codes are classified into five classes based on their first digit: informational (1xx), success (2xx), redirection (3xx), client error (4xx), and server error (5xx). The status codes are used by web developers and system administrators to diagnose and troubleshoot issues with web servers and applications.
It’s important to note that different web servers and applications may handle HTTP status codes differently. For example, some applications may customize error pages for specific status codes, while others may redirect users to a different page or display a generic error message.
What is HTTP
HTTP stands for Hypertext Transfer Protocol, and it is a communication protocol that is used to transfer data over the internet. It is the foundation of data communication for the World Wide Web and defines how messages are formatted and transmitted between web browsers and servers.
HTTP is a request-response protocol, where clients (such as web browsers) send requests to servers, and servers respond with a message that includes a status code and the requested data (such as a web page).
HTTP uses a uniform resource identifier (URI) to identify the requested resource and a set of methods, such as GET, POST, PUT, and DELETE, to indicate the desired action to be taken on that resource.
Type of HTTP Status Codes
HTTP status codes can be classified into five classes based on the first digit of the three-digit code:
- 1xx (Informational): These status codes indicate that the server has received the request and is continuing to process it. These are purely informational and don’t provide any indication of success or failure.
- 2xx (Success): These status codes indicate that the request was successful and the server was able to process it as expected. The most common 2xx codes are 200 OK and 204 No Content.
- 3xx (Redirection): These status codes indicate that the client needs to take additional steps to complete the request. For example, the server might indicate that the requested resource has been moved to a new location.
- 4xx (Client Error): These status codes indicate that the request was malformed, unauthorized, or could not be completed for some other reason attributable to the client. The most common 4xx codes are 400 Bad Request, 401 Unauthorized, and 404 Not Found.
- 5xx (Server Error): These status codes indicate that the server was unable to fulfill a valid request from the client, either because of a problem with the server itself or because of an error in the client’s request. The most common 5xx codes are 500 Internal Server Error and 503 Service Unavailable.
It’s worth noting that not all possible three-digit combinations of status codes are defined by the HTTP specification, so any unrecognized code should be treated as a generic server error.
100 (Informational) Status Codes
HTTP status codes in the 100 range are informational status codes that indicate that the server has received the client’s request and is continuing to process it. Here are the most common 100 status codes:
- 100 Continue: This status code indicates that the server has received the initial part of the request, and the client can proceed to send the remaining part of the request.
- 101 Switching Protocols: This status code indicates that the server is switching protocols and the client should switch to the new protocol specified in the response.
- 102 Processing: This status code is an interim response used to inform the client that the server has received the request and is still processing it.
- 103 Early Hints: This status code is an informational response that includes hints about the response that will be sent, allowing the client to start processing it before the final response is received.
The 100 status codes are typically used for communication between the client and server during the request-response cycle and are not indicative of success or failure.
200 (Success) Status Codes
HTTP status codes in the 200 range indicate that the request was successful and the server was able to process it as expected. Here are the most common 200 status codes:
- 200 OK: The request has succeeded.
- 201 Created: The request has been fulfilled, and a new resource has been created.
- 202 Accepted: The request has been accepted for processing, but the processing has not been completed.
- 203 Non-Authoritative Information: The request was successful, but the returned information may be from a third-party source.
- 204 No Content: The request was successful, but there is no representation to return.
- 205 Reset Content: The request was successful, but the user agent should reset the document view.
- 206 Partial Content: The server is delivering only part of the resource due to a range header sent by the client.
- 207 Multi-Status: The message body that follows is an XML message and can contain a number of separate response codes, depending on how many sub-requests were made.
- 208 Already Reported: The members of a DAV binding have already been enumerated in a preceding part of the (multistatus) response, and are not being included again.
- 226 IM Used: The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance.
The 200 status codes indicate that the request was successful and the server was able to process it as expected. The most common 200 status code is 200 OK, which indicates that the request was successful and the server is returning the requested data in the response body.
300 (Redirection) Status Codes
HTTP status codes in the 300 range indicate that the client needs to take additional steps to complete the request. Here are the most common 300 status codes:
- 300 Multiple Choices: The requested resource has multiple representations, each with its own URI, and the user or user agent can select one of them.
- 301 Moved Permanently: The requested resource has been permanently moved to a new URI.
- 302 Found: The requested resource has been temporarily moved to a new URI.
- 303 See Other: The response to the request can be found under a different URI.
- 304 Not Modified: Indicates that the resource has not been modified since the last time it was requested.
- 305 Use Proxy: The requested resource must be accessed through the proxy given by the Location field.
- 306 (Unused): This status code was used in a previous version of the HTTP/1.1 specification but is no longer used.
- 307 Temporary Redirect: The requested resource has been temporarily moved to a new URI.
- 308 Permanent Redirect: The requested resource has been permanently moved to a new URI.
The 300 status codes indicate that the client needs to take additional steps to complete the request, such as following a new URL or selecting one of multiple choices.
400 (Client Error) Status Codes
HTTP status codes in the 400 range indicate that the client has made an error in the request, and the server is unable to process it. Here are the most common 400 status codes:
- 400 Bad Request: The server could not understand the request due to invalid syntax.
- 401 Unauthorized: The request requires authentication, but the user has not provided valid credentials.
- 402 Payment Required: Reserved for future use.
- 403 Forbidden: The server understood the request but refuses to authorize it.
- 404 Not Found: The requested resource could not be found.
- 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 resource identified by the request is only capable of generating response entities that have content characteristics not acceptable.
- 407 Proxy Authentication Required: The client need to first authenticate itself with the proxy.
- 408 Request Timeout: The server timed out looking forward to the request.
- 409 Conflict: Request could not be completed due to a conflict with the current state of resource.
- 410 Gone: The requested resource is no longer available at the server and no forwarding address is known.
- 411 Length Required: The server requires the request to have a valid Content-Length header.
- 412 Precondition Failed: The server doesn’t meet one of the preconditions that the requester put on the request.
- 413 Payload Too Large: The request is larger than the output server is willing to process.
- 414 URI Too Long: Provided URI was too long for the server to process.
- 415 Unsupported Media Type: The request entity has the type of a media which the server or resource no longer support.
- 416 Range Not Satisfiable: The requested range cannot be served.
- 417 Expectation Failed: The server could not meet the requirements specified in the Expect header field.
- 418 I’m a teapot: 418 was defined in 1998 as one of the traditional IETF April Fools’ jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol, and is not expected to be implemented by actual HTTP servers.
- 421 Misdirected Request: The request was directed at a server that is not able to produce a response.
- 422 Unprocessable Entity: The request was well-formed but was unable to be followed due to semantic errors.
- 423 Locked: The resource that is being accessed is locked.
- 424 Failed Dependency: The request failed due to failure of a previous request.
- 426 Upgrade Required: The client should switch to a different protocol such as TLS/1.0.
- 428 Precondition Required: The origin server requires the request to be conditional.
- 429 Too Many Requests: The user has sent too many requests in a given amount of time.
- 431 Request Header Fields Too Large: The server is unwilling to process the request because its header fields are too large.
- 451 Unavailable For Legal Reasons: The server is denying access to the resource as a consequence of a legal demand.
The 400 status codes indicate that the client has made an error in the request, and the server is unable to process it. The most common 400 status code is 404 Not Found, which indicates that the requested resource couldn’t be found on the server.
500 (Server Error) Status Codes
HTTP status codes in the 500 range indicate that the server has encountered an error or is unable to fulfill the request. Here are the most common 500 status codes:
- 500 Internal Server Error: A generic error message, given when no more specific message is suitable.
- 501 Not Implemented: The server either does not recognize the request method, or it lacks the ability to fulfill the request.
- 502 Bad Gateway: The server was acting as a gateway or proxy and received an invalid response from the upstream server.
- 503 Service Unavailable: The server is currently unable to handle the request due to a temporary overload or maintenance of the server.
- 504 Gateway Timeout: The server was acting as a gateway or proxy and 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.
- 507 Insufficient Storage: The server is unable to store the representation needed to complete the request.
- 508 Loop Detected: The server detected an infinite loop while processing the request.
- 509 Bandwidth Limit Exceeded: The server has exceeded the bandwidth specified by the server administrator.
- 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.
The 500 status codes indicate that the server has encountered an error or is unable to fulfill the request. The most common 500 status code is 500 Internal Server Error, which indicates that the server has encountered an error and is unable to fulfill the request.
FAQ’s of HTTP Status Codes
Q: Why are HTTP Status Codes important?
A: HTTP Status Codes are important because they provide information about the status of the request and response between a client and a server. They can help diagnose and troubleshoot issues related to web requests and responses.
Q: How are HTTP Status Codes grouped?
A: HTTP Status Codes are grouped into five classes: informational, success, redirection, client error, and server error. The codes in each class have a specific meaning.
Q: What are some common HTTP Status Codes?
A: Some common HTTP Status Codes include 200 (OK), 404 (Not Found), and 500 (Internal Server Error).
Q: What is the difference between a 4xx and a 5xx HTTP Status Code?
A: HTTP Status Codes in the 4xx range indicate that there was an error on the client-side, while codes in the 5xx range generally indicate that there was an error on the server-side.
Q: How can I use HTTP Status Codes in my web development projects?
A: HTTP Status Codes can be used to build more robust and reliable web applications. For example, you can use HTTP Status Codes to handle errors, validate user input, and communicate with APIs.
Q: How can I troubleshoot issues related to HTTP Status Codes?
A: If you encounter issues related to HTTP Status Codes, you can troubleshoot them by reviewing the HTTP Status Code documentation, checking the server logs, and using web development tools like browser console and network analyzer.
HTTP Status Codes are an essential part of the web communication protocol that allow clients and servers to communicate effectively. By providing a standardized set of codes that indicate the status of web requests and responses, HTTP Status Codes help diagnose and troubleshoot issues related to web requests and responses.
Understanding HTTP Status Codes is crucial for web developers, system administrators, and anyone involved in web-related activities. Proper use and handling of HTTP Status Codes can make web applications more reliable, efficient, and user-friendly.