When a user browses the internet, the client, i.e., the web browser, corresponds with the webserver using HTTP. The user and the client exchange unique three-digit response status codes that refer to the status of a connection or a requested resource in transit, called HTTP Status Code.
In a way, HTTP acts as the traffic signal on the internet highway between browsers and servers, and status codes convey a variety of states, such as ongoing requests, successful connections, and, more importantly, errors and issues that crop up. While some are displayed right on the browser, others are displayed on the console.
Logically classified based on the first digit, HTTP response codes fall under five categories:
The four and five series of HTTP status codes are more serious than the other categories and form the bulk of all HTTP errors. In this article, we will be discussing the most encountered 4xx and 5xx series status codes.
Understanding these errors helps understand the possible root causes of errors and how to fix them. While many of these errors are well known, such as 401 - Unauthorized, 404 - Resource Not Found, and 408 - Request Timeout, others are encountered less frequently but are essential to know about for quick troubleshooting.
Depending on the source of the error (client or server), the administrator has to take a specific path to troubleshoot it. Though the error codes do not often zero in on the exact root causes, they indicate the logic with which a server or the client has experienced an issue, giving clues on where to dig further to find the actual root cause. Before investigating deeper, you may want to try the simple fixes first like refreshing browsers to track and spot any erroneous changes and check the log files (including web servers, if any).
A 401 error occurs when an API request authentication fails. Checking the WWW-Authenticate header can reveal the type of authentication the server expects. The reasons could be a login failure or access denial. A 401 error can also occur when the user requests access to an unauthorized page by actions like copying and pasting restricted URLs.
A 403 error occurs when the server understands the client but denies access to the requested resource. While a 401 error means authorization failed, a 403 error means that access is intentionally not allowed due to a management decision. It happens when an admin sets the permission to bar clients from accessing the page.
The most known among HTTP status codes, a 404 error occurs when an unrecognized URL fails to fetch an absent resource despite having a valid API endpoint. It happens when a location is removed (dead links), when the URL is entered incorrectly, when the server fails, or when a DNS error occurs. Not fixing this error may even dent SEO rankings.
A 405 error occurs when a server's request method (like GET, PUT, POST, DELETE) is unsupported. A 405 error occurs when an admin configures the web server in a certain way to suit their context and purpose, such as for security reasons. A 405 error cannot be fixed by a simple refresh, a restart, or cache clearing.
Also known as rate limiting, a 429 error indicates that too many user requests have been placed within a period. It could be linked to daily usage limits, email, and bandwidth restrictions set by the admin to control use.
A 500 error is a generic error response that points to a situation where the server cannot respond as expected. At the root, it could be a permission error, a timeout, a failed plugin, an incorrect syntax, or even a memory limit.
There are several ways to zero in on the reasons that may have triggered this error.
The second most encountered HTTP error code after 404, a 502 error occurs when the server fails to forward a request. It is known as a bad gateway, because the server acts as the gateway that streams data from multiple sources elsewhere.
A 502 error usually includes an appendix pointing to the erroneous endpoint, like 502 Bad Gateway Apache/Nginx. Among the causes for a 502 error include server crashes, overload on web servers (during attacks), faulty PHP code, or firewall-induced connection drops.
A 503 error occurs when the server cannot process the request temporarily. This is indicated in the HTTP header response under the Retry-After field. It could have several implications including server maintenance running, an overloaded server due to unexpected traffic surges or attacks, or even a client-side DNS configuration error.
The solution needs multiple approaches to find out why the server could not answer the request.
Also known as a connection timeout, this error means that one of the several network gateways, proxies, or cloud servers that a web server relies on to deliver the request has failed to resolve the query. The root cause is an intermediary server or a network connection failing to respond within a timeframe. Such delays break the chain of data transfer, and the webserver attempts to switch to a proxy server, which, when overwhelmed, results in a 504 error. Sometimes, it could also be an ISP-related error, which can be remedied by changing to a different DNS server.
HTTP status codes are a great starting point to investigate issues between the web server and the client. Therefore, remembering the important list of status codes and their implications is essential for web administrators to troubleshoot them, repair them, and ensure a great end-user experience.
Write for Site24x7 is a special writing program that supports writers who create content for Site24x7 “Learn” portal. Get paid for your writing.
Apply Now