๐ Introduction
Most of the web developers in the tech industry are already familiar with different HTTP response status codes, like, 200 OK, 404 NOT FOUND, and so on. These status codes are important in understanding how your HTTP request has been processed on the server side.
This quick read will help you shed light on different response status codes that HTTP supports.
If you want to learn about HTTP Request Methods first, feel free to jump to: Hello, I'm HTTP and these are my request methods๐๐ป
๐ฒ Response classes/groups
In the very basic way, responses are categorized in the 5 different classes as follows:
This way, you can easily get the idea on how your request has been processed on the server, just by looking at the first digit of the response code.
๐ถ HTTP Response Status Codes
Now let us get our hands dirty with each class:
Quick Guide:
WebDAV: Set of extensions to the Hypertext Transfer Protocol
Trash Icon --> Deprecated
Flask Icon --> Experimental
Star Icon --> Common/Important
ย
I will not be covering Deprecated methods as they are no longer in use anymore.
Please visit the links attached in the Reference section to learn more about these methods.
Informational Responses
100 Continue
- Tells client that their HTTP request is authorized to continue
- Client should ignore this response if the request is already finished
101 Switching Protocols
- This code is sent in response to an Upgrade request header from the client
- Tells client the protocol, the server is switching to
103 Early Hints
- This status code tells client to start pre-loading resources while the server prepares a response or preconnect to an origin from which the page will need resources
- This status code is primarily intended to be used with the Link header
Successful Responses
200 OK ๐
- The request succeeded
- Meaning of "Success" changes as per HTTP request Method
- GET => Resources has been fetched
- HEAD => Representation headers fetched, no message body
- PUT/POST => Result of the action performed is fetched in the message body
- TRACE => The message body contains the request as received by the server
201 Created
- The request succeeded, and a new resource was created as a result
- Typically after HTTP POST or some PUT requests
202 Accepted
- Notification heads-up to client that the request has been received but not yet acted upon
- Used 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
204 No Content
- There is no content to send for this request, but the headers are useful
205 Reset Content
- Tells the user agent to reset the document which sent this request
206 Partial Content
- Used when the client requests only part of a resource
207 Multi-Status (WebDAV)
- Conveys information about multiple resources, for situations where multiple status codes might be appropriate.
208 Already Reported (WebDAV)
- Used to avoid repeatedly enumerating the internal members of multiple bindings to the same collection
218 This is Fine
- This is an unofficial HTTP response that is used specifically by the Apache Web Server
- Indicate that there is a HTTP client error or HTTP server error
226 IM Used (HTTP Delta encoding) ๐
- 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
Redirection Messages
300 Multiple Choices
- The request has more than one possible response and the user agent or user should choose one of them
301 Moved Permanently ๐
- The URL of the requested resource has been changed permanently
- The new URL is given in the response.
302 Found
- This response code means that the URI of requested resource has been changed temporarily
- Further changes in the URI might be made in the future, so the same URI should be used by the client in future requests
303 See Other
- The server sent this response to direct the client to get the requested resource at another URI with a GET request
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
307 Temporary Redirect
- Imagine 302 Found again but this time the HTTP method (i.e. GET, POST...) used in the first request must not change
308 Permanent Redirect
- Imagine 301 Moved Permanently again but with the same restriction on HTTP method change
Client Error Responses
400 Bad Request ๐
- The server cannot or will not process the request due to client error
- Examples: malformed request syntax, invalid request message framing, or deceptive request routing
401 Unauthorized ๐
- Semantically this response means "unauthenticated"
- Meaning, the client must authenticate itself to get the requested response
402 Payment Required
- The initial purpose of this code was for digital payment systems, however this status code is rarely used and no standard convention exists
403 Forbidden ๐
- The client, although logged-in, 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
404 Not Found ๐
- Most common status code in web community
- The server cannot find the requested resource
- In the browser, this means the URL is not recognized.
- In an API, this can also mean that the endpoint is valid but the resource itself does not exist
- Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client
405 Method Not Allowed ๐
- The request HTTP method is known to the server but not supported for the target resource
406 Not Acceptable
- Sent when content negotiation doesnโt yield an acceptable content type
407 Proxy Authentication Required
- Similar to 401 Unauthorized but here the Authentication is needed to be done by a proxy
408 Request Timeout ๐
- Sent by server when the server would like to shut down unused or idle connections
409 Conflict
- The request conflicts with the serverโs current state
410 Gone
- The requested content has been permanently deleted, with no forwarding address
411 Length Required
- The server requires the Content-Length header field
412 Precondition Failed
- The clientโs preconditions are not met by the server
413 Content Too Large
- The request body is too big for the limits defined by server
414 URI Too Long
- Client has requested a URI which is longer than the server is willing to interpret
415 Unsupported Media Type ๐
- The media format added in the request data is not supported by the server
416 Range Not Satisfiable
- The ranges specified by the Range header field in the request cannot be fulfilled by the server
417 Expectation Failed
- Indicate that the conditions set by the client using the Expect header can not be satisfied
418 I'm a teapot โ
- Indicate that this server has been requested to brew coffee, yet, itโs a teapot
421 Misdirected Request
- Client error sent by a server that is unable to produce a response
- The client may retry the request using another connection.
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 dependent request
425 Too Early
- Indicates that the server is unwilling to risk processing a request that might be replayed
- Experimental
426 Upgrade Required
- Indicate that it is unwilling to process the request using the current protocol
- The server sends an Upgrade header in a this response to indicate the required protocol(s)
428 Precondition Required
- Indicate that HTTP requests of this type must be made conditionally, yet no precondition was included
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 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
- For example, a web page censored by a government
Server Error Responses
500 Internal Server Error ๐
- Most common status code
- This means that server has encountered a situation where it does not know how to handle it
- This error is generic, indicating that the server cannot find a more appropriate 5XX status code to respond with
501 Not Implemented
- Usually tells that method is available on the server but is not yet implemented as of now
- GET and HEAD methods are required to be supported by the server and therefore that must never return this code
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 not ready to handle the request
- Common causes are a server that is down for maintenance or that is overloaded
504 Gateway Timeout ๐
- This error response is given when the server is acting as a gateway to another resource 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
- The server has an internal configuration error
- and server can engage in transparent content negotiation
507 Insufficient Storage (WebDAV)
- Storage capacity of server is unable to store the representation needed of the request to succsfully complete it
508 Loop Detected (WebDAV)
- The server detected an infinite loop while processing the request
510 Not Extended
- The client request declares an HTTP Extension (RFC 2774) that should be used to process the request, but the extension is not supported
511 Network Authentication Required
- Indicates that the client needs to authenticate to gain network access
๐ธ Learn from the experts (they are cats!)
Visit http.cat and learn the HTTP response status codes in a very unique way ๐ผ
๐ฎ Browser Compatibility
๐ฑโ๐ Conclusion
This post might save you some time searching different web pages for getting an understanding on HTTP Response status codes.
I hope this post will help you in future, be it a help in your project or a last min study for your interview.
HAPPY CODING!!!โค๏ธ
Top comments (8)
I didn't know there are too many variations of response codes. Thank you
Welcome :)
Good hit! This definitely helps..However 418 was a new one!!
Thank you :)
I never thought that we have this many http responses. Definitely this is going to help me a lot.
Thanks !
Good one.
Thanks ๐๐ป