Today’s blog is all about HTTP status codes. What are the status codes of HTTP, and how many types of status codes do we have? We will see all these things in today’s blog. Today, we are going to see two things: what is the status code, and an introduction to all status code.

What is HTTP Status Code?

To understand this, we will look at these points so that we can understand it better. The first point is that it is in the first line. Where is the first line? In response. Whatever response comes to us, it is compulsory in the first line that it should be mentioned which is the status code of that response. Each response has a status code that is mentioned in the first line of the answer.

Indication of the Result of the Request

The status code is used to indicate the result of the request. That is, we asked for permission to access through a request; the status code is used to tell what the response has been. For example, if we do not have permission to access that thing, then a different status code will come; if we can access them, a different status code will come. If we are being redirected somewhere else, then a different status code will come. These status codes are visible to us in the first line inside the response.

Groups of HTTP Status Codes

The status code has been divided into a total of five groups. That is, the number of status codes we had has been divided into five groups. Within each group, there are different values that will have different meanings, which we will see later. The five groups are 1xx, 2xx, 3xx, 4xx, and 5xx. Here, X means that any value can come here. We also use X in ethical hacking, meaning any value can go here. 1xx means 101, 102; any value can appear there. These are the groups of status codes.

What is the Purpose of Status Codes?

Now inside these, we will get different status codes. For example, if we talk about 101 or 102, then what happens to that status code? What is the work inside it? We will understand all these things today. I hope you have understood this part of what is a status code. The status code is a code that is provided through HTTP and tells us what response we have received in return for the request that was made. It comes in the first line of the response through which it is confirmed whether we can access that website, will we reach somewhere else, do we not have permission to access it. We are going to learn all these things here.

Understanding Each Group of HTTP Status Codes

1xx – Informational Group

So here we will understand all the groups one by one. The first group is 1xx. Talking about the first group, they have been told information. That is, the name of the first group is the Informational Group, meaning it provides information about something. And inside this group, we are going to read only one status code, i.e., 100.

100 Status Code – Continue

What is the use of the 100 status code? What is its name? The name of this status code is Continue. The status code on 100 is called Continue. What is the meaning of this Continue? Let’s see with the definition: “Continue the connection for receiving complete message body using requests.” This means that the content of the body of the request we shared may not have been completed. There will still be a little left. In that case, we use 100, i.e., continue status codes. It means the connection will still be open from the server side. A request body is to be sent as long as this connection is open. As soon as I share the proper body or content of the request, then that connection will be closed. To keep that connection open continuously, so that we can send the complete HTTP request data there, 100 status codes are used. I hope you have understood the function of 100 status codes.

2xx – Successful Group

Let’s see which is the following status code we have. The next group is 2xx. What does it do? It shows that the request was successful. That is, whether your sent request has been successfully accepted or not, now you will get the response correct or not. The 2xx group tells us all these things.

200 Status Code – OK

If you want to see the first status code, i.e., the 200 status code, its name is OK. OK, that means everything is fine. You can access it. You can get whatever response you want. Let us try to understand it through its definition: “Request was successful & the response body contains the result of the request.” It means your request has been successfully accepted. Now the response will come in front of you, which will have a complete body, what you wanted.

For example, I want to access the WsCube Tech’s website. I will get the clear program now, i.e., whatever page I normally access, and the status code running there is 200.

201 Status Code – Created

Next is the 201 status code. What does it do? It means created. What is the meaning of created? We will be able to understand it only through definition: “Is returned in response to a PUT request to indicate that the request was successful.” If we have used the PUT method and tried to update any data using that method, then a reply will come in return, which will confirm to us that your data has been updated, the create method whose status code is 201.

What 201 is doing is that whenever you are updating any content using the PUT method, its confirmation is giving us a 201 status code. This means that your data has been successfully updated through PUT.

3xx – Redirection Group

Next is the 3xx group. Inside it, we are being told, “the client is redirected to a different resource.” That is, this whole group is doing work related to redirection.

301 Status Code – Moved Permanently

Let’s see what’s working. The first status code is 301. What is the meaning of 301? First, its name is Moved Permanently. That is, anything is wholly removed from someplace. The name defines this much. Let us understand this through definition: “Redirects to a different URL, using Location header. (Use New URL).” We have read about the Location Header. Where have you read? 

The problem is that the reason for redirecting is that the resource is not available there. As the name suggests, move permanently, it has moved from there. In this case, every time I enter the same URL, the same error will come. That is, I have to enter a new URL and specify the new address of the resource I want to access; then it will open. You must have understood the meaning of 301 that the resource you want to access is not yet available on the server. It has been removed from there; its URL or location has changed, and if it has changed, then you will have to add a new URL.

302 Status Code – Found

Next is the 302 status code. What does it do? Here it is written, Found. What is the meaning of Found? Understand it through definition: “Redirects to a different URL, using Location Header.” The Location Header has to be used everywhere. We know that there is use in redirection. We have read this part thoroughly in headers. “Revert to the original URL in subsequent requests.” This means that when we are redirected for any reason, we can go back to our URL.

Let’s assume that if we download something from the torrent website, then it gets redirected somewhere, and once our work is done, there it is using the 302 status code, which means found. As soon as we get that data, we will be able to access it; till then, we are redirected. There is no need to change the URL in this; the old URL comes into use. It will redirect it a couple of times, then we will be able to access it, depending on the code, what is causing the problem, and why it is being redirected.

304 Status Code – Not Modified

Next is 304. What does the 304 status code indicate? It is written here, Not Modified. We have read about it in headers. Let’s see the definition so that it becomes more apparent: “Instruct the browser to use its cached copy of the requested resource. (If-Modified-Since & If-None-Match).” When we were reading If-Modified-Since & If-None-Match, we knew that it would confirm whether the cache versions it had would work or the server had updated the data. That data needs to be taken from them. In short, we have read this.

How will the server tell us? When we used to access, and none of the data was modified, the server used to send a 304 status code response to let us know. In the first line of the response, it is written that the status code was 304.

For example, I asked about JavaScript. There is nothing new in that script. If not updated, then the server will send me a packet of Not Modified or status code along with the response. So that I can confirm that nothing has changed in our script, the cache version we have will work.

4xx – Client Error Group

Next, we have 4xx. What happens inside this? It indicates that the request could not be completed because of a client-side error. This group comes in whenever the problem is caused by a user, not a server. You do not have the authority to access it or access its permission; you do not have that permission, which means that the error is coming from the client side, not the server side.

401 Status Code – Unauthorized

Inside this, we have the first code, which is 401, i.e., Unauthorized. What does it mean to be unauthorized? What is the problem here? You do not have the authority to access this data. And we know this from the first line that the status code is coming. The name also says that you are unauthorized. Understand through the definition: “User authentication is required for resource access.” That is, the user is not authenticated to access the resource. Whenever we are not authorized or do not have permission to access that resource, 401 status code errors come up.

403 Status Code – Forbidden

Next is the 403 status code. What is Forbidden? Even if the user is authenticated, still not having permission to access the resource. The difference between 401 and 403 is that we were not authorized in 401, and we are authorized here, yet we do not have permission to access the resource. That is why 403 errors come up.

404 Status Code – Not Found

The last is 404, which means Not Found. It is used the most. You have seen many times that when the URL is entered incorrectly or we try to access a page that is not in our system, 404 errors come up. What does this mean? “Requested resource was not found at the given URL.” There are two ways for errors. One is that the resource is not there, or its URL is entered incorrectly. 404 status code errors come in both cases.

5xx – Server Error Group

Next, we have the 5xx group. What does it do? “It indicates that the request could not be completed because of a server-side error.” We do not have a hand in it. The user has no hand in it. The whole problem is happening because of the server.

500 Status Code – Internal Server Error

The first code we have inside this is 500, which means Internal Server Error. If you have any issue with the server, like any server-related problem, then the 500 status code error will come up.

502 Status Code – Bad Gateway

Next, we have 502, i.e., Bad Gateway. This means there is a problem between the servers. The gateway is down for some reason. In that case, 502 status code errors come up.

503 Status Code – Service Unavailable

And the last we have is 503, which means Service Unavailable. For some reason, the service is down. The service that should be running on our system is not running. It is called Service Unavailable. It usually happens because the server is not able to access it.

504 Status Code – Gateway Timeout

The last we have is 504. Gateway Timeout: “The connection timed out between servers, which is causing the delay.” That is why 504 errors are coming.

Conclusion

So here we have read about all the status codes in the HTTP status code group. I hope you have understood. If you still need clarification, please comment below. I will answer every comment. And if you have any other queries, feel free to ask. I hope this was informative and helped you understand the HTTP status codes better.

Categorized in:

Uncategorized,

Last Update: September 1, 2024