HTTP status codes made easy
On the internet, whatever you do is a request and whatever you get in return is a response. Let's take an example:
You enter google.com in the browser and hit enter ⇾ it's a request
Google.com gets opened ⇾ it's a response
You often see some common three digits of codes when anything goes wrong, a most common example of this is 404. You see it often while accessing a webpage, which doesn't exist it may happen due to any reason like a spelling mistake in URL, the webpage is deleted, or URL got changed. So, what does 404 mean? It's a code for identification like 007 for James Bond and Agent 47 for Hitman. 404 is the server's own way of communicating that the URL doesn't exist.
There are numerous types of response codes that you can see on the web while surfing. These response codes are classified and represented in the form of status codes; these codes are called HTTP Status Codes or HTTP response status codes.
Status Codes, when a person reads these words for the first time, he or she can easily come up to a conclusion that these are the codes which will describe the status. But the question that arises here is, the status of what 🤔? Now there is a simple explanation for this, these are the codes which will tell the status of the request made by a client to the server. Now let’s break this into a simpler and clearer form.
Every URL is like a request made to the server when a user hits that URL, a certain action, or process is performed on the server. For example, opening a web page is a request by the client (Your web browser) and providing required HTML resources is the response from the server. Now the response can be positive like the server has accepted the request 😊 and started working on it or it can be negative like the server is unable to find the requested resource 😣. In this way, a response can have different status and HTTP status codes represent them with the help of three digits.
HTTP status codes are sent by the server to your browser every time you hit an URL that requests a web page or a resource from the server, but most of the time it does not get into your observation except when the server finds some difficulties in responding to your request. Now, do you get the reason, why you often see 404? Following are some Common HTTP response status codes that can be easily remembered with the help of beautiful emojis
Classification of Status Codes
Status Codes are three-digit codes and are categorized into five different classes. Classification follows a simple notation that the first digit of the code represents the predefined standard classes of response, the other two just further defines the actual response.
First Digit | X | X |
---|---|---|
Class of Response | ||
1 | Informational | |
Indicates that request is recived and getting processed by the server | ||
2 | Success | |
Indicates that request is successfully processed by the server | ||
3 | Redirection | |
Indicates that request is redirected by the server | ||
4 | Client Error | |
Indicates that request made by client had soem error in it | ||
5 | Server Error | |
Indicates that request can't be processed because there is some error in the server |
1xx Informational:
Informational status codes indicate that request is received by the server. The server is working on it and the user should wait ⌚ for the final response. Some common informational status codes are described below.
100 Continue:
When a user sees 100 continue status code, this means that his request is accepted by the server successfully and other requests can be processed in continuation, the server will send a final response when work on that request will be completed.
101 Switching Protocol:
It means the server has accepted the client’s request and for doing so the server has to switch the protocol. Like you have one server that is running on MQTT protocol and you want to access it via HTTP.
102 Processing:
This status code says that the client’s request is accepted but the final response is not given by the server. It means the server is processing the request.
2xx Success:
Success status codes tell the user that his/her request is accepted and processed by the server. Let's discuss some of the common success status codes.
200 Successful:
This code means everything is OK and the server has accepted the request, and the request is succeeded. The actual meaning of 200 Sucess response depends on the type of request made for example:
In the case of a GET request, the response will contain an entity equivalent to the resource requested.
In the case of a POST request, the response will contain an entity describing or carrying the result of the action.
201 Created:
This code is generated whenever there is a POST request on the server. This type of response means that the request has been accepted and one or more new resources are created on the server.
202 Accepted:
It means that the request has been accepted but the server has not processed it yet. New resources will not be created until the processing is finished. These requests are put into the pending category because they can be rejected while processing.
203 Non-Authoritative Information:
This status code says that the request was successful, but the payload enclosed in the request is modified from origin server's 200 response by a transforming proxy. This status code also notifies the recipients about the applied transformation.
204 No Content:
It means the server has accepted the request and processed it successfully and no content is returned by the server in the response; it means the client will not have to navigate to a different web page.
3xx Redirection:
Redirection status codes are issued by the server whenever the address of the requested resource is changed. In these types of situations, users might have to put some effort to complete the request.
301 Moved Permanently:
This status code means that requested resource is moved permanently to a new URL and client will automatically redirect to the new URL. It is used to send SEO 'link-juice' to the new URL, for example, a company changes its name along with the website, in this case, using 301 redirections will tell search engines that old resources have permanently moved to the new location.
302 Found:
It means that the requested resource is moved temporarily to a new URL and it can be available again in the future. In this redirection, client redirects to the new URL, but search engines do not update their links to the new URL. In other words, it does not send SEO 'link-juice' to the new URL.
303 See Other:
303 See Other status code is returned in the case of GET, POST or DELETE requests. This code indicates that the requested resource is moved to a different URL and you should post the request to the new URL.
307 Temporary Redirect:
This status code means that the requested resource is moved temporarily to a different URL and a location header is returned in the response message which includes the new address.
308 Permanent Redirect:
This status code indicates that the requested resource is moved permanently to a different URL and a special location header is returned containing the new URL. It is same as 301 Moved Permanently but it does not allow the request method to be changed from POST
to GET
.
4xx Client Errors:
These types of error codes are given when an error is due to the client's mistake. Generally, Client Error status codes are issued when the request of the user is invalid like a typo in the URL, and the server is not going to respond on the request.
400 Bad Request:
This means that the server cannot accept the request because the syntax of the request is wrong from the client’s end.
401 Unauthorized:
This status error code appears when the request of the client is not accepted because the user must authenticate himself to complete the request with valid credentials.
403 Forbidden:
This status code is returned when you try to access a resource you are not authorized to. It indicates that the server has understood the request but refuses to provide the requested resource as it cannot authorize it.
404 Not Found:
This is one of the most common HTTP status codes, it means that the server is unable to find the requested resource. The resource is moved to a different address or user is doing a typo in the URL.
405 Method Not Allowed:
This status code indicates that requested resource exists on the server and it has recognized the request it cannot apply that HTTP Request Method on the resource.
406 Not Acceptable:
This indicates that the client has requested the response with certain Accept- headers which server cannot fulfil. This usually happens when the user agent (i.e. browser) asks the response in a specified character set (character encoding) but the server is not able to provide it.
407 Proxy Authentication Required:
This HTTP Status Codes Occurs when a client tries to access the resource through using a proxy. In such cases, the server asks for proper authentication credentials for completing the request.
408 Request Timeout:
As the name is indicating this status code tells that the client has not completed the request in the allotted timeout period of the server, so the server is intended to shut down the connection.
409 Conflict:
This status code is returned when the client's request cannot be completed because the server has established a rule there and it conflicts with the request.
410 Gone:
This status code is returned in the case when the requested resource is deleted permanently from the server and there are no alternative redirections provided for it.
411 Length Required:
This status code is returned by the server when the server is unable to accept the request without a defined Content-length header in the message body of the request.
414 Failed Dependency:
This status code is returned when the client request contains a method, and it could not be performed on the server as it was dependent on another action and that action failed.
415 Unsupported Media Type:
This error code is returned when the server refuses to accept the request due to unsupported format of the payload.
418 I'M A TEAPOT:
This status code has a weird error message, but its explanation is simple, this message is saying that client has asked for a coffee but as the requested item (Resource) is a Teapot and cannot provide the coffee, so the client should search for a different resource to get the coffee. In other words, request-method cannot be applied to the requested resource but can be applied to a different resource on the server.
429 Too Many Requests:
This status code is returned in the case when the user has sent too many requests in a given amount of time and the server is not able to operate on them. So, in such a condition server should return a Retry-After header which will indicate that after how much time should the user waits for making a new request.
5xx Server Errors:
Server Error status codes indicate that there is a problem with the server that it cannot process the request.
500 Internal Server Error:
This error indicates that something has This status code is returned when the server meets a condition where it cannot proceed and return the requested resource.
501 Not Implemented:
This status code is returned when the client's request contains an action that is not supported by the server i.e. that functionality is not implemented on the server.
502 Bad Gateway:
This status code is returned when there is trouble in communication between the servers. For much, a server gets an invalid response from another server.
503 Service Unavailable:
It means temporarily the requested resource cannot be provided by the server due to maintenance or overloading on the server.
504 Gateway Timeout:
This error occurs when a server is acting like a proxy server or a gateway and it did not get a response from the upstream server in a specific time.
HTTP Status Codes as Emojis
There is too much to remember, isn't it? don't worry I have simplified it for you to remember the description of common HTTP status codes. I would suggest you try to remember HTTP status code responses as emojis, for example:
Status Code | Description | Emoji |
---|---|---|
200 | Successful | 👍 |
201 | Created | 🆕 |
301 | Moved Permanently | 👉 |
303 | See Other | 👀 |
308 | Permanent Redirect | 🚀 |
400 | Bad Request | 👎 |
401 | Unauthorized | 🔐 |
404 | Not Found | 🤷♂️ |
408 | Request Timeout | ⌛ |
410 | Gone | 🏃 |
500 | Internal Server Error | 💻 |
502 | Bad Gateway | 😑 |
503 | Service Unavailable | 💔 |
Importance of HTTP status codes:
Status codes signify what is happening when you are trying to open a web page or use an app, whether it is going to open properly or there will be an issue. HTTP status codes help in troubleshooting the problem by identifying the status of the request. Moreover, status codes are also important for search engine optimization. Think of a website which is full of 404 HTTP status codes i.e. Resource not found error; it means many of its resources have moved to a different address. In such cases, search engines put these websites under an unmaintained category. It is important to put 301 status codes if there are moving resources, which redirects the user to the moved resource and removes the harms of 404 HTTP status codes.
Moreover, if a website returns HTTP status codes like 500 Internal Server Error, it means there is an issue on the server which can be triggered by the code or the database. In such cases, search engines drop the website ranking.
On the other hand, if a website returns more 200 HTTP status codes it means everything is healthy and running perfectly.
Did you like the idea of remembering HTTP status codes as emoji? or Do you have a better idea to remember HTTP status codes? do share it the comment section below.