/NodeJs-Learning

My complete Node.Js learning journey from beginner to advanced

Primary LanguageJavaScript

HTTP Status Codes Cheatsheet

1xx Informational

Status Code Message Description
100 Continue The initial part of a request has been received and has not yet been rejected by the server. The server intends to send a final response after the request has been fully received and acted upon.
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 An interim response used to inform the client that the server has accepted the complete request but has not yet completed it.

2xx Success

Status Code Nessage Description
200 OK The request has succeeded.

Cacheable by default.
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. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place.
203 Non-authoritative Information The request was successful but the enclosed payload has been modified from that of the origin server’s 200 OK response by a transforming proxy.

Cacheable by default.
204 No Content The server has successfully fulfilled the request and that there is no additional content to send in the response payload body.

Cacheable by default.
205 Reset Content The server has fulfilled the request and desires that the user agent reset the “document view”, which caused the request to be sent, to its original state as received from the origin server.
206 Partial Content The server is successfully fulfilling a range request for the target resource by transferring one or more parts of the selected representation that correspond to the satisfiable ranges found in the request’s Range header field.

Cacheable by default.
207 Multi-Status A Multi-Status response conveys information about multiple resources in situations where multiple status codes might be appropriate.
208 Already Reported Used inside a DAV: propstat response element to avoid enumerating the internal members of multiple bindings to the same collection repeatedly.
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.

A response received with a status code of 226 may be used by a cache, in conjunction with a cache entry for the base instance, to create a cache entry for the current instance.

3xx Redirection

Status Code Message Description
300 Multiple Choices The target resource has more than one representation, each with its own more specific identifier, and information about the alternatives is being provided so that the user (or user agent) can select a preferred representation by redirecting its request to one or more of those identifiers.

Cacheable by default.
301 Moved Permanently The target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs.

A user agent may change the request method from POST to GET for the subsequent request.

Cacheable by default.
302 Found The target resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client ought to continue to use the effective request URI for future requests.

A user agent may change the request method from POST to GET for the subsequent request.
303 See Other The server is redirecting the user agent to a different resource, as indicated by a URI in the Location header field, which is intended to provide an indirect response to the original request.
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 evaluated to false.
305 Use Proxy Deprecated, due to security concerns regarding in-band configuration of a proxy.
307 Temporary Redirect The target resource resides temporarily under a different URI and the user agent MUST NOT change the request method if it performs an automatic redirection to that URI.

Similar to 302 Found, except that it does not allow changing the request method from POST to GET.
308 Permanent Redirect The target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs.

Similar to 301 Moved Permanently, except that it does not allow changing the request method from POST to GET.

4xx Client Error

Status Code Message Description
400 Bad Request The server cannot or will not process the request due to something that is 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.

The user agent may repeat the request with a new or replaced Authorization header field.
402 Payment Required Reserved for future use.
403 Forbidden The server understood the request but refuses to authorize it.

The client may repeat the request with new or different credentials. However, a request might be forbidden for reasons unrelated to the credentials.
404 Not Found The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

Cacheable by default.
405 Method Not Allowed The method received in the request-line is known by the origin server but not supported by the target resource.

Cacheable by default.
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.

The server should generate a payload containing a list of available representation characteristics and corresponding resource identifiers from which the user or user agent can choose the one most appropriate.

A user agent may automatically select the most appropriate choice from that list.
407 Proxy Authentication Required Similar to 401 Unauthorized, but it indicates that the client needs to authenticate itself in order to use a proxy.
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. This code is used in situations where the user might be able to resolve the conflict and resubmit the request.

Conflicts are most likely to occur in response to a PUT request.
410 Gone The target resource is no longer available at the origin server and that this condition is likely to be permanent.

Cacheable by default.
411 Length Required The server refuses to accept the request without a defined Content-Length.
412 Precondition Failed One or more conditions given in the request header fields evaluated to false when tested on the server.
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 Request-URI Too Long The server is refusing to service the request because the request-target is longer than the server is willing to interpret.

Cacheable by default.
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 Requested Range Not Satisfiable None of the ranges in the request’s Range header field overlap the current extent of the selected resource or that the set of ranges requested has been rejected due to invalid ranges or an excessive request of small or overlapping ranges.
417 Expectation Failed The expectation given in the request’s Expect header field could not be met by at least one of the inbound servers.
418 I'm a teapot Any attempt to brew coffee with a teapot should result in the error code 418 I’m a teapot. The resulting entity body may be short and stout.

This status code is a reference to the Hyper Text Coffee Pot Control Protocol, which was released in 1998 as an April Fools’ joke.

Although this status code started as a joke, websites can technically use it as a response. Some sites use 418s for requests they don’t want to handle, such as automated queries. Use of 418 is rare and is not usually considered best practice.
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.

Cacheable by default.
422 Unprocessable Entity The server understands the content type of the request entity (hence a 415 Unsupported Media Type status code is inappropriate), and the syntax of the request entity is correct (thus a 400 Bad Request status code is inappropriate) but was unable to process the contained instructions.
423 Locked The source or destination resource of a method is locked.
424 Failed Dependency The method could not be performed on the resource because the requested action depended on another action and that action failed.
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.
429 Too Many Requests The user has sent too many requests in a given amount of time (“rate limiting”).

MUST NOT be stored by a cache.
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.
444 Connection Closed Without Response A non-standard status code used to instruct nginx to close the connection without sending a response to the client, most commonly used to deny malicious or malformed requests.

This status code is not seen by the client, it only appears in nginx log files.
451 Unavailable For Legal Reasons The server is denying access to the resource as a consequence of a legal demand.

Cacheable by default.
499 Client Closed Request A non-standard status code introduced by nginx for the case when a client closes the connection while nginx is processing the request.

5xx Server Error

Status Code Message Description
500 Internal Server Error The server encountered an unexpected condition that prevented it from fulfilling the request.
501 Not Implemented The server does not support the functionality required to fulfill the request.

Cacheable by default.
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.
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 major version of HTTP that was used in the request message.
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 method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request.
508 Loop Detected The server terminated an operation because it encountered an infinite loop while processing a request with Depth: infinity. This status indicates that the entire operation failed.
510 Not Extended The policy for accessing the resource has not been met in the request. The server should send back all the information necessary for the client to issue an extended request.
511 Network Authentication Required The client needs to authenticate to gain network access.
599 Network Connect Timeout Error This status code is not specified in any RFCs but is used by some HTTP proxies to signal a network connect timeout behind the proxy to a client in front of the proxy.