What is HTTP Status code ?
When a user make web request or a HTTP request to a web server using his/her browser, the web server responds with different HTTP status codes as a response. The HTTP status codes are dependable on the type of response that the server gives to the user browser.
You can also check out our youtube video on this topic.
For example, we might have seen Error 404 Not Found multiple times while browsing the website. Code 404 is an HTTP status code. 404 Not Found means that the resource we are looking for on the website is not available. The resource can be a file, image, video, post, etc.
In the image above, we tried to look for lmao in our website hacknopedia.com but the file/post or path lmao is not present there. Hence, the web server gave us a 404 Not Found response which is an HTTP status code. Okay, let’s discuss about different types of HTTP status codes.
- 1xx: Informational
- 2xx: Success
- 3xx: Redirection
- 4xx: Client Error
- 5xx: Server Error
All the Status codes in the range of 100 are Informational, 200 are Success, 300 are for redirection, 400 are for Client-side error and 500 are for server-side error. Now, we will see each category in detail.
1XX: HTTP Status Codes For Informational Message
2XX: HTTP Status Codes for Success
3XX: HTTP Status Code For Redirection
4XX: Client Side Error HTTP Codes
|405||Method not allowed|
|407||Proxy Authentication required|
|413||Payload too large|
|414||Request URI too long|
|415||Unsupported Media type|
|416||Requested Range Not satisfiable|
|429||Too many requests|
|431||Request Header too large|
|499||Client closed request|
5XX: Server Error HTTP Codes
|500||Internal Server Error|
|505||HTTP version not supported|
|511||Network Authentication Required|
|599||Network Connect Time out Error|
Common HTTP Status Codes
- 200 OK: This response code is sent by server when our request is received and successfully processed in server.
- 201 Created: Request is accepted and and new resource is in the process of creation.
- 202 Accepted: Request is accepted for procession but the process is not completed.
- 301 Moved Permanently: The requested page has been moved to a new location or new URL permanently.
- 302 Found: Requested page is moved to a new URL temporarily.
- 401 Unauthorized: User authentication must be performed in order to request the object or make the request successful. The requested page needs username and password or any other type of authentication.
- 403 Forbidden: The request would not be success even we are authenticated. The page is protected from being accessed.
- 404 Not Found: The requested object is not found found in the server. The object can be a path, page or a URL.
- 405 Method Not Allowed: The web server has received and recognized the request, but has rejected the specific HTTP method as it is not supported by the server.
- 411 Content Length Required: The server requires Content-Length header in its request for processing the request.
- 500 Internal Server Error: An error has occurred in the server, which prevented it from completing the request.
- 503 Service Unavailable: The web server is unable to complete a user request due to various reasons such as server crash, high traffic in server, lack of resource in server etc.
Now we will discuss how browser uses these HTTP status codes in real life. We will visit some website and check how the browser and the web server communicates with each other using these status codes. if you are new to HTTP Request and HTTP Response and how they works. Check out this post on Introduction to HTTP Headers.
At first we will browse hacknopedia.com in our browser and check network tab to see the response from server.
As we can see in above image we received 200 OK response from web server. That indicates we received success response from server as a result webpage is loaded in our browser.
Let us try checking admin panel of a website at hacknopedia.com/wp-admin/. Browse https://hacknopedia.com/wp-admin in browser and check network request.
As we can see in above image our visited URL received 302 Found from server, that means we received a new URL from server where we are redirected for login. In the step-3 we got new location set in our response header, where we will get another webpage.
Let try another thing, now we will try to make request to some sensitive file in web server, which is generally protected by server for security purpose. Visit the URL: http://hacknopedia.com/wp-config.php and we will see response from server.
As we saw, we got Forbidden from server because the file is protected by server and cannot be accessed directly.