There are many different HTTP status codes that can be returned by a server in response to a client’s request. Here are all the HTTP status codes along with a brief explanation of what they indicate:
1xx (Informational)
- 100 Continue: The server has received the request headers and the client should proceed to send the request body.
- 101 Switching Protocols: The server understands and is willing to comply with the client’s request, via the Upgrade header field, for a change in the application protocol being used on this connection.
- 102 Processing: The server has received and is processing the request, but no response is available yet. This can be used to avoid the “lost update” problem, where a client GETs a resource’s state, modifies it, and PUTs it back to the server, when meanwhile a third party has modified the state on the server, leading to a conflict.
- 103 Early Hints: The server is likely to send a final response with the header fields included in the informational response.
Note:
1xx status codes indicate that the server has received and is continuing to process the request, but the final outcome is not yet known. They are intended to inform the client that the server has received the request and that the client should continue to wait for the final response.
100 Continue is a status code that can be used in cases where the client has sent a request with the Expect: 100-continue header, which asks the server whether the client should proceed with sending the request body.
101 Switching Protocols is typically used in cases where the client requests that the server switch to a different protocol, such as upgrading from HTTP/1.1 to HTTP/2.
102 Processing is a status code indicating that the server has received and is processing the request, but it’s not in a position to send a final response yet, for example when processing large resources or doing a long computation.
103 Early Hints status code is part of the HTTP/2 Push feature, which sends a set of headers to the client to let it know that resources are available to be pushed before it sends the final response, this allows the server to give the client a ‘heads up’ that it might be able to get some of the resources it needs in advance.
It’s worth noting that 1xx status codes are not very common in practice and are typically used in specific situations where a more detailed interim response is needed.
2xx (Successful)
- 200 OK: The request has succeeded. The payload sent in the response depends on the request method.
- 201 Created: The request has been fulfilled and has resulted in one or more new resources being 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 server is returning information from a third-party source.
- 204 No Content: The server has successfully fulfilled the request and there is no additional information to send back, like after a DELETE request.
- 205 Reset Content: The request has been successfully processed, and the user agent SHOULD reset the document view which caused the request to be sent.
- 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 previous reply to this request, and are not being included again.
- 218 Non-standard: This is a non-standard HTTP status code used to indicate that the request is being rejected by the server due to a client-side issue, such as a client certificate that is not valid.
- 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.
Note: All 2xx status codes indicate that the request was successful, but they convey different information about the specifics of the success. And it’s important to use the correct status code because it helps the client understand what to expect from the response, and also can be used to make sure that the request was processed correctly on the server side.
3xx (Redirection)
- 300 Multiple Choices: The request has more than one possible response. The user-agent or user should choose one of them.
- 301 Moved Permanently: The requested resource has been permanently moved to a new URL provided in the Location header field.
- 302 Found: The requested resource resides temporarily under a different URL.
- 303 See Other: The response to the request can be found under another URI using the GET method.
- 304 Not Modified: A conditional GET or HEAD request has been received and would have resulted in a 200 OK response if it were not for the fact that the condition has been evaluated as false.
- 305 Use Proxy: The requested resource must be accessed through the proxy given by the Location field.
- 307 Temporary Redirect: The request should be repeated with another URI, but future requests can still use the original URI.
- 308 Permanent Redirect: The request and all future requests should be repeated using another URI.
Note: All 3xx status codes indicate that the client needs to take additional action in order to complete the request, usually by following a redirect to a different URI. The main difference between the different 3xx status codes is the type of redirect (temporary vs. permanent) and the method that should be used to access the resource (GET vs. other methods)
4xx (Client Error)
- 400 Bad Request: The request could not be understood or was missing required parameters.
- 401 Unauthorized: The request requires user authentication.
- 402 Payment Required: Reserved for future use.
- 403 Forbidden: The server understands the request, but it refuses to authorize it.
- 404 Not Found: The requested resource could not be found.
- 405 Method Not Allowed: The method received in the request-line is known by the origin server but not supported by the target resource.
- 406 Not Acceptable: The target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request, and the server is unwilling to supply a default representation.
- 407 Proxy Authentication Required: The client needs to authenticate itself to proxy.
- 408 Request Timeout: The server timed out waiting for the request.
- 409 Conflict: The request could not be processed because of conflict in the request, like an edit conflict between multiple simultaneous updates.
- 410 Gone: The resource is no longer available at the server and no forwarding address is known. This condition is expected to be considered permanent.
- 411 Length Required: This status code indicates that the server refuses to accept the request without a valid value for the Content-Length header.
- 412 Precondition Failed: The server does not meet one of the preconditions that the requester put on the request.
- 413 Payload Too Large: The server is refusing to process a request because the request payload is larger than the server is willing or able to process.
- 414 URI Too Long: The server is refusing to service the request because the request-target is longer than the server is willing to interpret.
- 415 Unsupported Media Type: The origin server is refusing to service the request because the payload is in a format not supported by this method on the target resource.
- 416 Range Not Satisfiable: This status code is used in the context of HTTP range requests, and indicates that the server cannot satisfy the range specified in the request headers.
- 417 Expectation Failed: This status code indicates that the server could not meet the expectations specified in the Expect request header.
- 418 I’m a teapot: This status code is a humorous extension of the HTTP specification, and indicates that the server is a teapot and cannot complete the requested action.
- 421 Misdirected Request: The request was directed at a server that is not able to produce a response.
- 422 Unprocessable Entity: The server understands the content type of the request entity and the syntax of the request entity is correct but it was unable to process the contained instructions.
- 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.
- 428 Precondition Required: The 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 refuses to process the request because the request header fields are too large.
- 451 Unavailable For Legal Reasons: The server is unable to provide the requested resource due to legal reasons.
Note: 4xx status codes indicate that there was an error with the client’s request. These errors can be caused by a variety of factors, such as the client providing an invalid or missing parameter in the request, or the client not having the necessary permissions to access the requested resource.
It’s important to note that 4xx errors indicate a problem with the client’s request, rather than a problem with the server or the requested resource. Therefore, it’s the client’s responsibility to fix the problem and resubmit the request.
5xx (Server Error)
- 500 Internal Server Error: An error occurred on the server.
- 501 Not Implemented: The server does not support the requested function.
- 502 Bad Gateway: The server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request.
- 503 Service Unavailable: The server is not ready to handle the request, like during server maintenance.
- 504 Gateway Timeout: The server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request.
- 505 HTTP Version Not Supported: The server does not support the requested HTTP version.
- 506 Variant Also Negotiates: The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process.
- 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.
- 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.
Note: Each of the 5xx status code indicates that something went wrong on the server side. When a server returns a 5xx status code, it’s indicating that there’s an error that it cannot recover from. The specific error message that a 5xx status code represents can vary depending on the implementation of the server and the specific error that occurred. It’s important to carefully review and understand the specific error message to identify the cause of the problem and develop an appropriate solution.
It’s worth noting that 5xx error codes should be used sparingly and only when the server is unable to perform a request due to an unexpected condition.
Understanding the meaning of the status code and what it represents is crucial in order to implement the right logic to handle the response coming from the server.
It’s also worth noting that HTTP status codes are grouped into classes, where the first digit of the status-code defines the class of response. Each class of status code conveys a different message.
This article is created based on experience but If you discover any corrections or enhancements, please write a comment in the comment section or email us at contribute@devopsforu.com. You can also reach out to us from Contact-Us Page.
For more information please visit HTTP Wikipedia
Follow us on LinkedIn for updates!