List of HTTP response status codes

Contents
A list of HTTP response status codes - 1xx, 2xx, 3xx, 4xx, and 5xx and an ???? Easter egg
Contents

In computer networking, a server may send a response code to indicate the status of a request sent by a client. The response code may also be called an HTTP status code, an HTTP response code, or an HTTP status message.

API coders should be aware of HTTP error codes because they can indicate whether a request was successful or not. If an error code is returned, the coder can then take appropriate action to fix the problem.

There are many possible HTTP status codes that could be returned from a RESTful API, but some of the most common ones are 404 (Not Found), 401 (Unauthorized), and 400 (Bad Request).

The first digit of the status code defines the class of response. The second and third digits indicate a specific response within that class. The HTTP 1.1 specification defines the following classes of response codes:

1xx (Informational): The request was received, continuing process

This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty line. Since HTTP/1.0 did not define any 1xx status codes, servers MUST NOT send a 1xx response to an HTTP/1.0 client unless the client has made a request with the Expect request header field set to 100-continue as described in section 8.2.3 of [RFC2616].

A client must be prepared to accept one or more 1xx status responses prior to a regular response, even if the client does not expect a 100 (Continue) status message. Unexpected 1xx status responses MAY be ignored by a user agent.

Proxies MUST forward 1xx responses, unless the connection between the proxy and its client has been closed, or unless the proxy itself requested the generation of the 1xx response. (For example, if a proxy adds a “Expect: 100-continue” field to a request, it is not required to forward the corresponding 100 (Continue) response(s).)

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 NOT send a 100 (Continue) response if the request already includes People usually expect to get 100-continue before this interim response, but they didn’t get 100 (continue) before this interim response.

101 Switching Protocols

The server understands and is willing to comply with the client’s request, via the Upgrade message header field (section 14.42 of [RFC2616]), 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 that terminates the 101 response.

The protocol should be switched only when it is advantageous to do so. People who use resources that need real-time or synchronous features might want to use a real-time protocol instead of an older version of HTTP to send them.

A 101 response may be used to inform the client about the new capabilities of a server that were not previously known to the client. The server should include any new or changed capability information in the 101 response. If the client uses the Upgrade header field and the server does not recognize the request method used, it should respond with a status code of 502 (Bad Gateway).

102 Processing

As a WebDAV request may contain many sub-requests involving file operations, it may take a long time to complete the request. This code indicates that the server has received and is processing the request, but no response is available yet. This prevents the client from timing out and assuming the request was lost.

2xx (Successful): The request was successfully received, understood, and accepted.

This type of status code shows that the client’s request was received, understood, and agreed to.

200 OK

The request has succeeded. The information returned with the response is dependent on the method used in the request. For example,

In the response, an entity corresponding to the requested resource is sent in the response;

HEAD The entity-header fields corresponding to the requested resource are sent in the response without any message body;

POST an entity describing or containing the action’s result;

Trace an entity containing the request message as received by the end server.

202 Accepted

The request has been accepted for processing, but the processing has not yet been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place. There isn’t a way to send a status code again from an asynchronous operation like this one.

203 Non-Authoritative Information (since HTTP/1.1)

The returned metainformation in the entity-header is not the definitive set as available from the origin server, but is gathered from a local or a third-party copy. The set presented MAY be a subset or superset of the original version. For example, including local annotation information about the resource might result in a superset of the metainformation known by the origin server. The origin server should generate a Vary header field if it performs content negotiation on the request headers.

204 No Content

The server has fulfilled the request but does not need to return an entity-body and might want to return updated metainformation. There may be new or updated metainformation in the form of entity-headers, which if present, should be linked to the variant you requested.

If the client is a user agent, it should not change its document view from that which caused the request to be sent. This response is mostly for people who want to be able to input actions that don’t change the user agent’s active document view. However, any new or updated metainformation should be applied to the document that is currently in the user agent’s active view.

The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields.

205 Reset Content

The server has fulfilled the request, and the user agent should reset the document view that caused the request to be sent. This response is primarily intended to allow input for actions to take place via user input, followed by a clearing of the form in which the user input was given so that the user can easily initiate another input action. The response must not include an entity.

206 Partial Content

The server is delivering only part of the resource (byte serving) due to a range header sent by the client. The range header is used by tools like wget to make it possible to download large files even on slow connections.

The two most common status codes used by servers to indicate the range of a file are:

206 Partial Content

When the server must return only part of the file, due to a range header sent by the client.

416 Requested Range Not Satisfiable: When the client has requested a range of the file that the server cannot provide, due to the size of the file or the configuration of the server.

3xx (Redirection): Further action needs to be taken in order to complete the request.

The client needs to take additional action to complete the request. This class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request. The action required MAY be carried out by the user agent without interaction with the user if and only if the method used in the second request is GET or HEAD. A client should be able to detect infinite redirection loops, since such loops generate network traffic for each redirection.

Note: previous versions of this specification recommended a maximum of five redirections. Content developers should be aware that there might be clients that implement such a fixed limitation.

300 Multiple Choices

It can be any one of a set of representations, each with a specific location, and agent-driven negotiation information (section 12) is being given so that the user (or user agent) can choose the representation that best fits their needs and send their request to that location.

Responses to requests that are not HEAD should include a list of resource characteristics and locations from which the user or user agent can choose the one that is right for them.The entity format is specified by the media type given in the Content-Type header field. Depending on the format and the capabilities of the user agent, the best choice may be made for you.However, this specification does not define any standard for such automatic selection.

If the server has a preferred choice of representation, it should include the specific URL for that representation in the Location field; user agents MAY use the Location field value for automatic redirection. This response is cacheable unless indicated otherwise.

301 Moved Permanently

The requested resource has been assigned a new permanent URI and any future references to this resource should use one of the returned URIs. Clients with link-editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise.

The new permanent URI should be given by the Location field in the response. Unless the request method was HEAD, the response entity SHOULD include a brief hypertext note with a hyperlink to the new URI(s).

Requests other than GET or HEAD should not be automatically redirected by the user agent unless they can be confirmed by the user. This could change what conditions the user was in when the request was made, and this could be bad for the user.

302 Found

This response code means that the URI of the requested resource has been changed temporarily. Probably, the new URI would be given by the Location field in the response.

This response code is probably the most famous one due to its frequent occurrence on the web. Some Web applications and frameworks use the 302 status code as an HTTP status code for their own redirect logic.

303 See Other

The response to the request can be found under another URI using the GET method. When a POST (or PUT/DELETE) message is sent, it should be assumed that the server has received the data and the redirect should be sent with a separate GET message.

304 Not Modified

If the client has made a conditional GET request and access is allowed but the document has not been modified, the server should respond with this status code. The 304 response MUST NOT contain a message body and thus is always terminated by the first empty line after the header fields.

The response MUST include the following header fields:

date, unless its omission is required by section 14.18.1.

If a clock less origin server obeys these rules, and proxies and clients add their own date to any response received without one, caches will operate correctly.

305 Use Proxy

The requested resource MUST be accessed through the proxy given by the Location field. The Location field gives the URI of the proxy. The recipient is expected to repeat this single request via the proxy. 305 responses must only be generated by origin servers.

306 (Unused)

The 306 status code was used in a previous version of the specification, is no longer used, and the code is reserved.

307 Temporary Redirect

The requested resource temporarily resides under a different URI. Since the redirection might be altered on occasion, the client should continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.

The temporary URI should be given by the Location field in the response. Unless the request method was head, the response entity should include a brief hypertext note with a hyperlink to the new URI(s).

307 is a status code for a request that isn’t GET or head. If the user agent receives this code, it should not automatically redirect the request unless they can confirm it with the user. This could change the conditions under which the request was made.

308 Permanent Redirect

The request, and all future requests, should be directed to the given URI.

The permanent URI should be given by the Location field in the response. No matter what kind of request method was used, unless it was head, the response should have some text that says what new URIs have been added and links to them.

This response is cacheable unless indicated otherwise.

4xx (Client Error): The request contains bad syntax or cannot be fulfilled

The 4xx class of status code is intended for cases in which the client seems to have erred. Only if the server is replying to a head request should the server include an entity that explains what happened and whether it is a temporary or long-term problem. These status codes are applicable to any request method. User agents should display any included entity to the user.

400 Bad Request

The request could not be understood by the server due to malformed syntax. The client should not repeat the request without modifications.

401 Unauthorized

The request requires user authentication. The response must include a WWW-Authenticate header field containing a challenge applicable to the requested resource. The client MAY retry the request with a different authorization header field. If the request already included authorization credentials, then the 401 response indicates that authorization has been refused for those credentials. As long as the user agent has tried to authenticate at least once before getting this response, the user should be able to get in.

The user should be presented with the entity that was given in the response since that entity may include relevant diagnostic information. HTTP access authentication is explained in “HTTP Authentication: Basic and Digest Access Authentication”.

402 Payment Required

This code is reserved for future use.

403 Forbidden

The server understood the request, but is refusing to fulfill it. Authorization will be ineffective, and the request SHOULD NOT BE REPEATED. 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. This status code is used when the server doesn’t want to say why the request was turned down, or when there is no other way to respond.

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 with a list of methods that can be used to get the resource.

406 Not Acceptable

The resource identified by the request is only capable of generating response entities that have content characteristics that are not acceptable according to the accepted headers sent in the request.

Unless the request was a head request, the response should include an entity containing a list of available entity characteristics and location(s) from which the user or user agent can select the most appropriate. The entity format is specified by the media type given in the Content-Type header field. The selection of the most appropriate choice may be performed automatically, depending on the format and capabilities of the user agent. However, this specification does not define any standard for such automatic selection.

407 Proxy Authentication Required

This code is similar to 401 (Unauthorized), but indicates that the client must first authenticate itself with the proxy. The proxy MUST return a Proxy-Authenticate header field containing a challenge applicable to the proxy for the requested resource. The client MAY REPLY with a suitable Proxy-Authorization header field. HTTP access authentication is explained in “HTTP Authentication: Basic and Digest Access Authentication”.

408 Request Timeout

The client did not produce a request within the time that the server was prepared to wait. The client may repeat the request without modifications at any later time.

409 Conflict

The request could not be completed due to a conflict with the current state of the resource. This code is only allowed in situations where it is expected that the user might be able to resolve the conflict and resubmit the request. The response body should include enough information for the user to recognize the source of the conflict. Ideally, the response entity would include enough information for the user or user agent to fix the problem. However, that might not be possible and is not required.

Conflicts are most likely to occur in response to a PUT request. For example, if versioning were being used and the entity being PUT included changes to a resource that conflicted with those made by an earlier (third-party) request, the server might use the 409 response to indicate that it can’t complete the PUT at this time.

A 409 response is cacheable by default.

410 Gone

The requested resource is no longer available at the server, and no forwarding address is known. This condition should be considered permanent. Clients with link editing capabilities should delete references to the Request-URI after user approval. 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. This response is cacheable by default.

411 Length Required

The server refuses to accept the request without a defined content length. The client MAY repeat the request if it includes a valid Content-Length header field in the request message containing the length of the message body.

412 Precondition Failed

The precondition given in one or more of the request-header fields was evaluated as false when it was tested on the server. This response code lets the client set up rules for the current resource metainformation (header field data) so that the method can’t be used on a resource other than the one it was meant for.

413 Request Entity Too Large

The server is refusing to process a request because the request entity is larger than the server is willing or able to process. The server may close the connection to prevent the client from continuing the request.

If the condition is temporary, the server should include a Retry-After header field to indicate that it is temporary and after what time the client MAY try again.

414 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. It’s very rare for this to happen, but it can happen when a client converts a POST request to a GET request with long query information, or when the client descends into a “URI black hole” of redirection (e.g., a redirected URI prefix that points to the end of itself).

415 Unsupported Media Type

The server isn’t going to serve the request because the request is in a format that isn’t supported by the requested resource for the method that the server wants.

416 Requested Range Not Satisfiable

A server should return a response with this status code if a request included a range request header field, and none of the range-specifier values in this field overlap the current extent of the selected resource, and the request did not include an if-range request header field. (For byte-ranges, this means that the first-byte-pos of all of the byte-range-spec values is greater than the current length of the selected resource.)

To get a byte-range request, you need to get this status code. The response should include a Content-Range entity-header field that tells you how many bytes you’ve chosen.This response MUST NOT use the multipart/byterange content-type.

417 Expectation Failed

The expectation given in the Expect request-header field could not be met by this server, or, if the server is a proxy, the server has unambiguous evidence that the request could not be met by the next-hop 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. The RFC specifies that this code should be returned by teapots requested to brew coffee. This HTTP status is used as an Easter egg on some websites, including Google.com.

Unofficial code

419 Authentication Timeout

Not a part of the HTTP standard, 419 Authentication Timeout denotes that a previously valid authentication has expired. It is used as an alternative to 401 Unauthorized in order to differentiate from otherwise authenticated clients being denied resources with 404 Not Found, 405 Method Not Allowed, 406 Not Acceptable, 408 Request Timeout, 409 Conflict, 410 Gone, 411 Length Required, 412 Precondition Failed, 413 Request Entity Too Large, or 414 Request-URI Too Long.

Unofficial code

420 Method Failure

Not part of the HTTP standard, but defined by Spring in the HttpStatus class to be used when a method fails. This status code is deprecated by Spring.

421 Misdirected Request

The request was directed at a server that was not able to produce a response. (for example, because of connection reuse).

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 the failure of a previous request (e.g., a PROPPATCH).

425 Too Early

The server does not want to risk executing a request that may be replayed.

426 Upgrade Required

The client should switch to a different protocol, such as TLS/1.0, given in the Upgrade header field.

428 Precondition Required

The origin server requires the request to be conditional. It is intended to prevent “the ‘lost update’ problem, where a client GETS a resource’s state, modifies it, and PUTs it back to the server, while in the meantime, 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. intended for use with rate-limiting schemes.

430 Request Header Fields Too Large

Rather than the 429 Too Many Requests response code, Shopify uses this one instead. When too many URLs are requested in a certain amount of time, this response code is used.

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.

A server operator has been asked by a judge to stop people from getting access to a resource or a group of resources that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451.

5xx (Server errors): the problem was caused by the server.

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 lacks the ability to fulfill the request. Usually, this implies future availability (e.g., a new feature of a web-service API). A 501 response is cacheable by default; that is, unless caching headers instruct otherwise.

502 Bad Gateway

The server was acting as a gateway or proxy, and it got an invalid response from the upstream server when it tried to connect to it.

503 Service Unavailable

The server is currently unavailable (because it is either overloaded or down for maintenance). Generally, this is a temporary state.

504 Gateway Timeout

As a gateway or proxy, the server did not get a quick answer 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 in the server’s configuration.

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. intended for use by intercepting proxies used to control access to the network (e.g., “captive portals” used to require agreement to terms of service before granting full Internet access via a Wi-Fi hotspot).

In conclusion

A response code is given by a server to a client in order to indicate the status of a request that the client has submitted. The response code is also referred to as an HTTP status code or an HTTP response code in certain instances. For example, 404 (Not Found), 401 (Unauthorized), and 400 are some of the most often seen (Bad Request). We have listed all error codes just in case you’ll need to figure this out.

Touchless API Discovery
Discover all unknown APIs in your organization & reduce cloud costs.
BOOK DISCOVERY ASSESSMENT
• Powered by BLST Security
Share this article
Subscribe for weekly API Security news