Learn HTTP Status Codes
Get latest articles directly in your inbox
HTTP Status codes are 3-digit numbers which specify the status of whether a particular HTTP request was completed or not. These codes are a part of header in response.
These codes are not part of site content but rather are a way of informing the client about the status of request sent to server. It is important for any developer to learn about HTTP status codes since proper error codes are super useful in debugging applications. Incorrect HTTP codes lead to confusion, these are set of defined standard codes which are followed all over web.
You probably would have seen 400 Page not found
or 500 internal server error
while browsing the web. These are some of the HTTP response status codes.
In this article, we will be exploring various types of HTTP status codes and understand when and where to use which code.
Types of HTTP Status Codes
There are five different groups which contain few response status code. The first digit in the 3-digit code represents the class/group of HTTP status code. The five groups are -
- Informational responses - 1xx [
100
–199
] - Successful responses - 2xx [
200
–299
] - Redirects - 3xx [
300
–399
] - Client errors - 4xx [
400
–499
] - Server errors - 5xx [
500
–599
]
Let’s explore each of them in detail -
Informational Responses - 1xx 📘
Code | Description | Explanation |
---|---|---|
100 | Continue | Client should continue with the request. Some part of the request has been received by the server, but as long as it has not been rejected, . |
101 | Switching Protocols | Client has asked the server to switch protocols and the server acknowledges with code |
Successful responses - 2xx ✔️
Code | Description | Explanation |
---|---|---|
200 | OK | The request is successful. The response depends on HTTP Methods - GET, POST, etc. |
201 | Created | New resource created and successful response. |
202 | Accepted | The request has been accepted for processing, but the processing has not been completed. |
203 | Non-Authoritative Information | Information in header is from a local/third-party copy, not from the original server. |
204 | No Content | Response has status code and header but not body. |
205 | Reset Content | This response requires that the requester reset the document view. |
206 | Partial Content | Server is returning partial data of the size requested defined by Range header |
Redirects - 3xx 👉
Code | Description | Explanation |
---|---|---|
300 | Multiple Choices | More than one possible response. Client chooses one of them. |
301 | Moved Permanently | The requested page has moved to a new url. All future request should be made at new url. |
302 | Found | Requested resource resides temporarily under a different url. |
303 | See Other | Server directs the client to get the requested resource at another url. |
304 | Not Modified | Response has not been modified, use the cached version. |
305 | Use Proxy | Requested resource MUST be accessed through the proxy given by the Location field |
307 | Temporary Redirect | Client should continue to use the Request-URI for future requests. |
Client errors - 4xx ❌
Code | Description | Explanation |
---|---|---|
400 | Bad Request | Server could not understand the request due to invalid/malformed syntax. |
401 | Unauthorized | Client should authenticate itself to get the requested response. |
402 | Payment Required | Reserved for future |
403 | Forbidden | Client does not have access rights to the content, even with authentication this request cannot be fulfilled. |
404 | Not Found | Server cannot find the requested page. |
405 | Method Not Allowed | HTTP method in request is not allowed. |
406 | Not Acceptable | Server is capable of generating only content that is not acceptable by client as specified in header. |
407 | Proxy Authentication Required | Authentication is required to be done by a proxy. |
408 | Request Timeout | Server timed out. It did not receive request from client within specific time. |
409 | Conflict | The request could not be completed due to a conflict with the current state of the resource |
410 | Gone | Requested page is no longer available. Similar to 404 but this is permanent. |
411 | Length Required | Server requires Content-Length header. |
412 | Precondition Failed | Precondition given in some request-header fields evaluated to false when it was tested on the server. |
413 | Request Entity Too Large | Request is too large for server to process. |
414 | Request-URI Too Long | Query string that is too large for the server to process. |
415 | Unsupported Media Type | Entity of the request is in a format not supported by the requested resource. |
429 | Too many request | Server cannot process these many request in given time. (Rate limiting) |
Server errors - 5xx 🔻
Code | Description | Explanation |
---|---|---|
500 | Internal Server Error | Server has met unexpected condition which has caused an error. |
501 | Not Implemented | Server doesn’t support the functionality required to fulfill the request. |
502 | Bad Gateway | Server has received an invalid response from the another resource(eg. third party payment request) thus request cannot be fulfilled. |
503 | Service Unavailable | Server is overloaded or currently down. |
504 | Gateway Timeout | Gateway did not get response in time. |
505 | HTTP Version Not Supported | HTTP version used in the request is not supported by the server. |
Resources
- https://httpstatuses.com/
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
- Explanation by IETF ✔️
- Learn with dogs and cats ❤️️
You can find browser compatibity data for status code here.
I am working on a side project called Devsheets 🚀 where you can find all cheatsheet for your development. Do Contribute and support!
Liked the article? Consider supporting me ☕️
I hope you learned something new. Feel free to suggest improvements ✔️
I share regular updates and resources on Twitter. Let’s connect!
Keep exploring 🔎 Keep learning 🚀
Liked the content? Do support :)