Table of Contents
HTTP response status codes
HTTP status codes are a set of codes that are returned by web servers to indicate the status of a request made by a client, such as a web browser or a web-based application. The status codes are included in the HTTP response sent by the server after the client sends a request to access a resource. There are five classes of HTTP status codes:
- Informational responses (100–199)
- Successful responses (200–299)
- Redirects (300–399)
- Client errors (400–499)
- Server errors (500–599)
1xx — Informational responses
This category indicates that the request was received and understood. It is issued on a provisional basis while request processing continues. It alerts the client to wait for a final response. The message consists only of the status line and optional header fields, and is terminated by an empty line.
100 continue
The client SHOULD continue with its request. This interim response is used to inform the client that the initial part of the request has been received and has not yet been rejected by the server. The client SHOULD continue by sending the remainder of the request or, if the request has already been completed, ignore this response. The server MUST send a final response after the request has been completed.
101 Switching Protocols
The server understands and is willing to comply with the client's request, via the Upgrade message header field, for a change in the application protocol being used on this connection. The server will switch protocols to those defined by the response's Upgrade header field immediately after the empty line which terminates the 101 response. The protocol SHOULD be switched only when it is advantageous to do so.
For example, switching to a newer version of HTTP is advantageous over older versions, and switching to a real-time, synchronous protocol might be advantageous when delivering resources that use such features.
102 Processing (WebDAV)
The 102 (Processing) status code is an interim response used to inform the client that the server has accepted the complete request, but has not yet completed it. This status code SHOULD only be sent when the server has a reasonable expectation that the request will take significant time to complete. As guidance, if a method is taking longer than 20 seconds (a reasonable, but arbitrary value) to process the server SHOULD return a 102 (Processing) response. The server MUST send a final response after the request has been completed.
Methods can potentially take a long period of time to process, especially methods that support the Depth header. In such cases the client may time-out the connection while waiting for a response. To prevent this the server may return a 102 (Processing) status code to indicate to the client that the server is still processing the method.
Learn more about WebDAV.
103 Early Hints
This status code is primarily intended to be used with the Link header, letting the user agent start preloading resources while the server prepares a response.
2xx — Successful responses
This class of status code indicates that the client's request was successfully received, understood, and accepted.
200 OK
GET
: The resource has been fetched and transmitted in the message body.HEAD
: The representation headers are included in the response without any message body.PUT
orPOST
: The resource describing the result of the action is transmitted in the message body.TRACE
: The message body contains the request message as received by the server.
201 Created
The request succeeded, and a new resource was created as a result. This is typically the response sent after POST
requests, or some PUT
requests.
202 Accepted
The request has been received but not yet acted upon. It is noncommittal, since there is no way in HTTP to later send an asynchronous response indicating the outcome of the request.
It is intended for cases where another process or server handles the request, or for batch processing.
203 Non-Authoritative Information
This response code means the returned metadata is not exactly the same as is available from the origin server, but is collected from a local or a third-party copy.
This is mostly used for mirrors or backups of another resource. Except for that specific case, the 200 OK
response is preferred to this status.
204 No Content
There is no content to send for this request, but the headers may be useful. The user agent may update its cached headers for this resource with the new ones.
205 Reset Content
Tells the user agent to reset the document which sent this request.
206 Partial Content
This response code is used when the Range
header is sent from the client to request only part of a resource.
The Range
HTTP request header indicates the part of a document that the server should return. Several parts can be requested with one Range header at once, and the server may send back these ranges in a multipart document.
207 Multi-Status (WebDAV)
Conveys information about multiple resources, for situations where multiple status codes might be appropriate.
208 Already Reported (WebDAV)
Used inside a <dav:propstat>
response element to avoid repeatedly enumerating the internal members of multiple bindings to the same collection.
226 IM Used
It is a non-standard HTTP status code that indicates the server has fulfilled a request for a resource that has been used for the creation of a response.
The status code 226 is typically used in conjunction with the HTTP Range header, which is used to request a specific portion of a resource. When a server returns a 226 response, it indicates that the requested resource has been used to create the response, and the response body contains a representation of the result of the operation.
3xx — Redirection messages
This class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request.
300 Multiple Choices
When a server returns a 300 status code, it indicates that the requested resource has multiple representations, each with its own specific location, and the client must choose which one to access. The server should include a list of available options in the response body, along with their respective URIs and any other relevant information.
HTTP status code 300 is not a specific redirection code, but rather a generic code that indicates multiple choices are available for the requested resource.
301 Moved Permanently
This status code indicates that the requested resource has been permanently moved to a new URL. The client should update its bookmarks or links to the new URL.
302 Found
This status code indicates that the requested resource has been temporarily moved to a new URL. The client should use the new URL for this request, but the old URL may still be valid in the future.
303 See Other
This status code indicates that the client should redirect to a different URL to complete the request. This is often used in response to a POST request to prevent the client from submitting the same form data again if they refresh the page.
304 Not Modified
This is used for caching purposes. It tells the client that the response has not been modified, so the client can continue to use the same cached version of the response.
305 Use Proxy
Defined in a previous version of the HTTP specification to indicate that a requested response must be accessed by a proxy. It has been deprecated due to security concerns regarding in-band configuration of a proxy.
306 unused
This response code is no longer used; it is just reserved. It was used in a previous version of the HTTP/1.1 specification.
307 Temporary Redirect
This has the same semantics as the 302 Found
HTTP response code, with the exception that the user agent must not change the HTTP method used: if a POST
was used in the first request, a POST
must be used in the second request.
308 Permanent Redirect
This status code indicates that the requested resource has been permanently moved to a new URL. The client should update its bookmarks or links to the new URL, and use the new URL for all future requests.
4xx — Client error responses
The 4xx class of status code is intended for cases in which the client seems to have erred. Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable to any request method. User agents SHOULD display any included entity to the user.
400 Bad Request
A 400 Bad Request response is typically returned when the client sends a request that the server is unable to understand or process. This can occur due to various reasons, including incorrect syntax, missing or invalid parameters, or invalid request message framing.
For example, a client might receive a 400 Bad Request response if it attempts to send a POST request with missing or invalid form data, or if it sends a request to an unsupported API endpoint.
401 Unauthorized
The request requires user authentication. The response MUST include a WWW-Authenticate header field. If the request already included Authorization credentials, then the 401 response indicates that authorization has been refused for those credentials.
402 Payment Required
This response code is reserved for future use. The initial aim for creating this code was using it for digital payment systems, however this status code is used very rarely and no standard convention exists.
403 Forbidden
The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized
, the client's identity is known to the server.
If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. If the server does not wish to make this information available to the client, the status code 404 (Not Found)
can be used instead.
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.
The 410 Gone
status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address.
405 Method Not Allowed
The request method is known by the server but is not supported by the target resource. For example, an API may not allow calling DELETE
to remove a resource.
406 Not Acceptable
The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.
This response is sent when the web server, after performing server-driven content negotiation, doesn't find any content that conforms to the criteria given by the user agent.
407 Proxy Authentication Required
This is similar to 401 Unauthorized
but authentication is needed to be done by a proxy.
408 Request Timeout
408 request timeout indicates that the server did not receive a complete request from the client within the expected time window. This can happen when the client takes too long to send a request, or when the server is overloaded and cannot process the request within the expected time limit.
The 408 Request Timeout error response is typically used to notify the client that the server is still waiting for the client to complete the request, and that the client should try again later.
409 Conflict
This response is sent when a request conflicts with the current state of the server.
410 Gone
This response is sent when the requested content has been permanently deleted from server, with no forwarding address. Clients are expected to remove their caches and links to the resource.
411 Length Required
Server rejected the request because the Content-Length
header field is not defined and the server requires it.
412 Precondition Failed
The client has indicated preconditions in its headers which the server does not meet.
413 Payload Too Large
Request entity is larger than limits defined by server. The server might close the connection or return an Retry-After
header field.
414 URI Too Long
The URI requested by the client is longer than the server is willing to interpret.
415 Unsupported Media Type
The media format of the requested data is not supported by the server, so the server is rejecting the request.
416 Range Not Satisfiable
The range specified by the Range
header field in the request cannot be fulfilled. It's possible that the range is outside the size of the target URI's data.
417 Expectation Failed
This response code means the expectation indicated by the Expect request header field cannot be met by the server.
418 I'm a teapot
This code 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. However, known implementations do exist. An Nginx HTTP server uses this code to simulate goto-like behaviour in its configuration.
421 Misdirected Request
The request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI.
422 Unprocessable Content (WebDAV)
The request was well-formed but was unable to be followed due to semantic errors.
423 Locked (WebDAV)
The resource that is being accessed is locked.
424 Failed Dependency (WebDAV)
The request failed due to failure of a previous request.
425 Too Early
Indicates that the server is unwilling to risk processing a request that might be replayed.
426 Upgrade Required
The server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol.
428 Precondition Required
The origin server requires the request to be conditional. Intended to prevent "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.
429 Too Many Requests
The user has sent too many requests in a given amount of time ("rate limiting").
431 Request Header Fields Too Large
The server is unwilling to process the request because its header fields are too large. The request may be resubmitted after reducing the size of the request header fields.
451 Unavailable For Legal Reasons
The user agent requested a resource that cannot legally be provided, such as a web page censored by a government.
5xx — Server error responses
The server failed to fulfill an apparently valid request.
Response status codes beginning with the digit "5" indicate cases in which the server is aware that it has erred or is incapable of performing the request.
500 Internal Server Error
The server has encountered a situation it does not know how to handle.
501 Not Implemented
The request method is not supported by the server and cannot be handled. The only methods that servers are required to support (and therefore that must not return this code) are GET
and HEAD
.
502 Bad Gateway
This error response means that the server, while working as a gateway to get a response needed to handle the request, got an invalid response.
503 Service Unavailable
The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.
This response should be used for temporary conditions and the Retry-After HTTP header should, if possible, contain the estimated time before the recovery of the service.
504 Gateway Timeout
This error response is given when the server is acting as a gateway and cannot get a response in time.
505 HTTP Version Not Supported
The HTTP version used in the request is not supported by the server.
506 Variant Also Negotiates
HTTP 506 is an error status code that indicates that the server has detected an internal configuration error.
Specifically, HTTP 506 occurs when the server has an opaque configuration (an opaque data type is a data type whose concrete data structure is not defined in an interface) for handling requests for a specific resource, such as a media type, encoding, or language.
507 Insufficient Storage (WebDAV)
The 507 http code indicates that the server is unable to fulfill the request because it lacks the necessary storage space to complete the action. This error is commonly used by WebDAV servers to indicate that there is not enough space on the server to store the requested resource.
508 Loop Detected (WebDAV)
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
Indicates that the client needs to authenticate to gain network access.
Useful links
This article is created from HTTP status code information found at ietf.org, Wikipedia and MDN Web Docs.
Youssef's Newsletter
Trust me, I won't spam you.