HTTP Status Codes
HTTP - Status Codes
Section titled “HTTP - Status Codes”The HTTP Status Code in a server’s response is a 3-digit integer indicating the outcome of the request. The first digit classifies the response type:
| S.N. | Code Class | Description |
|---|---|---|
| 1 | 1xx: Informational | Request received, continuing process. These are interim responses, often followed by a final response. |
| 2 | 2xx: Success | The action was successfully received, understood, and accepted. |
| 3 | 3xx: Redirection | Further action needs to be taken by the user agent to complete the request. |
| 4 | 4xx: Client Error | The request contains bad syntax or cannot be fulfilled by the server. |
| 5 | 5xx: Server Error | The server failed to fulfill an apparently valid request due to an error on the server. |
HTTP status codes are extensible. While applications should be prepared to handle any status code by at least understanding its class, the following lists common and important codes.
1xx: Informational Responses
Section titled “1xx: Informational Responses”| Status Code & Reason Phrase | Description |
|---|---|
| 100 Continue | The server has received the request headers and the client should proceed to send the request body (e.g., in a POST request). Or, if the request is already finished, ignore this response. |
| 101 Switching Protocols | The server is switching protocols as requested by the client (via an Upgrade header). Commonly used for WebSockets. |
| 102 Processing (WebDAV) | The server has received and is processing the request, but no response is available yet. Prevents the client from timing out. |
| 103 Early Hints | Used to send some response headers before the final HTTP message. Allows a browser to start preloading resources while the server is still preparing the main response. |
2xx: Successful Responses
Section titled “2xx: Successful Responses”| Status Code & Reason Phrase | Description |
|---|---|
| 200 OK | The request has succeeded. The payload sent in a 200 response depends on the request method (e.g., resource for GET, status for HEAD). |
| 201 Created | The request has been fulfilled, resulting in the creation of a new resource. The URI of the new resource is often returned in the Location header. |
| 202 Accepted | The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon. Useful for asynchronous operations. |
| 203 Non-Authoritative Information | The returned meta-information is from a local or third-party copy, not from the origin server, and might be outdated. |
| 204 No Content | The server successfully processed the request but is not returning any content. Often used for DELETE requests or PUT requests where no body is returned. |
| 205 Reset Content | The server successfully processed the request, and tells the user agent to reset the document view which caused the request to be sent (e.g., clear a form). |
| 206 Partial Content | The server is delivering only part of the resource (byte serving) due to a Range header sent by the client. |
3xx: Redirection Messages
Section titled “3xx: Redirection Messages”| Status Code & Reason Phrase | Description |
|---|---|
| 300 Multiple Choices | The request has more than one possible response. The user agent or user should choose one of them. (Rarely used). |
| 301 Moved Permanently | The target resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Search engines update their links. |
| 302 Found | The target resource resides temporarily under a different URI. As this redirection may be altered on occasion, the client SHOULD continue to use the effective request URI for future requests. Historically, browsers would change POST to GET on 302; use 303 or 307 for clearer semantics. |
| 303 See Other | The response to the request can be found under a different URI and SHOULD be retrieved using a GET method on that resource. Typically used after a POST to prevent re-submission. |
| 304 Not Modified | A conditional GET or HEAD request was received and the resource has not been modified. The client can use its cached version. No message body. |
| 305 Use Proxy (Deprecated) | The requested resource MUST be accessed through the proxy given by the Location field. Deprecated due to security concerns. |
| 307 Temporary Redirect | The target resource resides temporarily under a different URI. The user agent MUST NOT change the request method if it makes an automatic redirection to that URI. (e.g., POST remains POST). |
| 308 Permanent Redirect | The target resource has been assigned a new permanent URI. The user agent MUST NOT change the request method if it makes an automatic redirection to that URI. (e.g., POST remains POST). |
4xx: Client Error Responses
Section titled “4xx: Client Error Responses”| Status Code & Reason Phrase | Description |
|---|---|
| 400 Bad Request | The server cannot or will not process the request due to something perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). |
| 401 Unauthorized | The request has not been applied because it lacks valid authentication credentials for the target resource. Often accompanied by a WWW-Authenticate header. |
| 402 Payment Required | Reserved for future use. Sometimes used by APIs to indicate a payment issue. |
| 403 Forbidden | The server understood the request but refuses to authorize it. Authentication will not help and the request SHOULD NOT be repeated. |
| 404 Not Found | The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. |
| 405 Method Not Allowed | The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource. |
| 406 Not Acceptable | The server cannot generate a response that matches the list of acceptable values defined in the request’s proactive content negotiation headers (e.g., Accept, Accept-Charset). |
| 407 Proxy Authentication Required | Similar to 401, but indicates that the client must first authenticate itself with the proxy. The proxy MUST send a Proxy-Authenticate header field. |
| 408 Request Timeout | The server did not receive a complete request message within the time that it was prepared to wait. |
| 409 Conflict | The request could not be completed due to a conflict with the current state of the target resource. Often used for PUT requests that would create a conflict. |
| 410 Gone | The target resource is no longer available at the origin server and this condition is likely to be permanent. If the server does not know, or has no facility to determine, whether or not the condition is permanent, the status code 404 (Not Found) SHOULD be used instead. |
| 411 Length Required | The server refuses to accept the request without a defined Content-Length header. |
| 412 Precondition Failed | One or more conditions given in the request header fields (e.g., If-Match, If-Unmodified-Since) evaluated to false when tested on the server. |
| 413 Payload Too Large | (Formerly Request Entity 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 | (Formerly Request-URI Too Long) The server is refusing to service the request because the Request-URI is longer than the server is willing to interpret. |
| 415 Unsupported Media Type | The 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 | (Formerly Requested Range Not Satisfiable) The client has asked for a portion of the file (e.g., with a Range header), but the server cannot supply that portion. |
| 417 Expectation Failed | The expectation given in an Expect request-header field could not be met by this server. |
| 418 I’m a teapot | An April Fools’ joke RFC (RFC 2324). While humorous, it’s sometimes used by developers as an Easter egg or for specific error states. |
| 422 Unprocessable Entity (WebDAV; RFC 4918) | 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 (e.g., semantic errors like invalid field values). |
| 429 Too Many Requests | The user has sent too many requests in a given amount of time (“rate limiting”). A Retry-After header might be included to indicate how long to wait before making a new request. |
5xx: Server Error Responses
Section titled “5xx: Server Error Responses”| Status Code & Reason Phrase | Description |
|---|---|
| 500 Internal Server Error | A generic error message, given when an unexpected condition was encountered and no more specific message is suitable. |
| 501 Not Implemented | The server does not recognize the request method or lacks the ability to fulfill the request. Usually this implies future availability (e.g., a new feature of a web service API). |
| 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 currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay. A Retry-After header might be included. |
| 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, or refuses to support, the HTTP protocol version that was used in the request message. |