HTTP Status Codes Guide
When we surf the web, we interact with various websites and web servers every day. Have you ever wondered what happens behind the scenes when you click on a link or submit a form? That’s where HTTP status codes come into play. In this article, we’ll take a deep dive into the world of HTTP status codes, demystifying their significance and shedding light on how they affect our online experiences.
HTTP, or Hypertext Transfer Protocol, is the foundation of data communication on the World Wide Web. It enables the transfer of information between web servers and browsers, facilitating our seamless internet browsing experience. Every time you request a webpage, your browser sends an HTTP request to the server, and the server responds with an HTTP status code to indicate the outcome of the request.
The Three Digit Numbers: Understanding the Categories
HTTP status codes consist of three-digit numbers that fall into five distinct classes. The initial digit of the code determines the class, while the last two digits do not play a role in categorization. Let’s explore the key classes of HTTP status codes:
1xx: Informational Responses – These codes indicate that the request has been received and the server is continuing to process it.
2xx: Successful Responses – These status codes indicate that the client’s request was successfully received, understood, and processed by the server.
3xx: Redirection Messages – When a website or resource has moved or changed, these codes guide the browser on where to find it.
4xx: Client Errors – These codes occur when there’s an issue with the client’s request.
5xx: Server Errors – When the server encounters an error while processing a request, it generates these codes.
HTTP Status Codes
Let’s explore some of the HTTP status codes you might frequently encounter while browsing the web:
1xx Informational Codes
100 Continue: this code indicates that the initial part of the request has been received and understood, and the server is willing to proceed with the client’s request.
101 Switching Protocols: when a client sends an “Upgrade” header in the request, the server responds with this code to indicate a successful change of protocol.
102 Processing: the server has received the request and is currently processing it, but there is no response available yet.
2xx Success Codes
200 OK: this status code means the request was successful, and the server has returned the requested data or performed the requested action.
201 Created: when a new resource is successfully created as a result of the request, the server responds with this code.
202 Accepted: the server has accepted the request for processing, but the completion of the process may take time.
204 No Content: the server successfully processed the request, but there is no data to send back as a response.
206 Partial Content: when a client requests specific parts of a large resource using range headers, the server responds with this code to indicate a partial response.
3xx Redirection Codes
300 Multiple Choices: when a client’s request can be resolved to multiple locations, the server sends this code to provide a list of options.
301 Moved Permanently: this code indicates that the requested resource has moved permanently to a new URL, and clients should update their bookmarks or links accordingly.
302 Found (Moved Temporarily): historically, this code was used for temporary redirects. However, it’s often recommended to use “303 See Other” or “307 Temporary Redirect” instead.
303 See Other: the server responds with this code to direct the client to a different URI, which can be retrieved using a GET method.
304 Not Modified: when a client sends a conditional GET request, and the resource hasn’t changed since the last request, the server returns this code, instructing the client to use the cached copy.
307 Temporary Redirect: similar to 302, this code indicates a temporary redirect. However, unlike 302, the client must use the same method for the redirected request.
308 Permanent Redirect: this code is used for permanent redirects, similar to “301 Moved Permanently.”
4xx Client Error Codes
400 Bad Request: the server couldn’t understand the client’s request due to malformed syntax or invalid parameters.
401 Unauthorized: authentication Required for Requested Response. The HTTP status code 401 indicates that the client must provide authentication credentials to access the requested resource. This code is employed when the client’s request lacks valid or sufficient authentication information or when the provided credentials are incorrect.
403 Forbidden: the user lacks the required permissions to access the requested resource.
404 Not Found: perhaps one of the most well-known codes, it indicates that the requested resource is not available on the server.
405 Method Not Allowed: when the client tries to use an HTTP method that the server does not allow for the requested resource.
408 Request Timeout: the server timed out waiting for the client’s request.
429 Too Many Requests: this code indicates that the client has sent too many requests to the server within a specific timeframe.
5xx Server Error Codes
500 Internal Server Error: a generic server-side error occurred, and the server couldn’t fulfill the client’s request.
501 Not Implemented: the server doesn’t support the functionality required to fulfill the request.
502 Bad Gateway: the server functioning as an intermediary or proxy encountered an erroneous response from the upstream server.
503 Service Unavailable: the server is currently unavailable due to maintenance or being overloaded. Clients should try again later.
504 Gateway Timeout: the server acting as a gateway or proxy didn’t receive a timely response from the upstream server.
505 HTTP Version Not Supported: the server cannot process the HTTP protocol version utilized in the request.