top of page
Search
Writer's pictureLARUS Foundation

Learn the Web and HTTP Status Codes

Web and HTTP status codes are essential for understanding the outcome of a web page request. These codes, standardized by the Internet Engineering Task Force (IETF), are issued by a server in response to a client's request. They provide critical information about whether the request was successful or if there was an error.


Here’s a comprehensive look at some of the most common HTTP status codes and their meaning.


Common HTTP Status Codes


1. Error 400 (Bad Request)

  • Description: This status code indicates that the server cannot or will not process the request due to a client error, such as malformed request syntax.

  • Example: Sending a request with incorrect syntax or invalid query parameters can result in a 400 error.


2. Error 401 (Unauthorized)

  • Description: This status code means that the request requires user authentication. It typically occurs when the user needs to log in to access the resource.

  • Example: Accessing a restricted website area without logging in will usually result in a 401 error.


3. Error 403 (Forbidden)

  • Description: The server understands the request but refuses to authorize it. This can happen if the user does not have the necessary permissions to access the resource.

  • Example: Accessing a server's directory without the necessary permissions will result in a 403 error.


4. Error 404 (Not Found)

  • Description: The server cannot find the requested resource. This often occurs when the URL is incorrect or the resource has been moved or deleted.

  • Example: If a user tries to access "www.example.com/nonexistentpage", and the page does not exist, the server will return a 404 error.


5. Error 405 (Method Not Allowed)

  • Description: The request method is known by the server but has been disabled and cannot be used.

  • Example: Attempting to use a POST method on a form that only accepts GET requests can lead to a 405 error.


Where's the Error 402? Do they exist?

The HTTP 402 status code, known as “Payment Required,” is not commonly used or recognized by most web browsers. It typically indicates an issue with a payment transaction. This code is considered rare and is classified as "experimental" or still in development.


6. Error 500 (Internal Server Error)

  • Description: A generic error message is given when an unexpected condition is encountered, and no more specific message is suitable.

  • Example: Server misconfigurations or unexpected runtime errors in server-side code can result in a 500 error.


7. Error 502 (Bad Gateway)

  • Description: The server was acting as a gateway or proxy and received an invalid response from the upstream server.

  • Example: When a server acts as a proxy and the upstream server it accesses returns an invalid response, a 502 error is triggered.


8. Error 503 (Service Unavailable)

  • Description: The server is not ready to handle the request, often because it is down for maintenance or overloaded.

  • Example: Websites that experience high traffic volumes or are undergoing maintenance might return a 503 status code.


9. Error 504 (Gateway Timeout)

  • Description: The server is not ready to handle the request, often because it is down for maintenance or overloaded.

  • Example: Websites that experience high traffic volumes or are undergoing maintenance might return a 503 status code.


Where's the Error 501? Do they exist?

The HTTP 501 error typically occurs when the hosting server is offline or unavailable, meaning it cannot fulfill the request. This server error response code means that your web server does not support the functionality required for access and does not recognize the request method.


10. Error 301 (Moved Permanently)

  • Description: The requested resource has been permanently moved to a new URI, and the server provides the new URI in the response.

  • Example: If "www.example.com/oldpage" is permanently moved to "www.example.com/newpage", the server will return a 301 status code along with the new location.


11. Error 302 (Found)

  • Description: The requested resource resides temporarily under a different URI. It tells the client to use the provided URL for future requests.

  • Example: When a page is temporarily moved to a new URL, the server will respond with a 302 status code.


12. Error 307 (Temporary Redirect)

  • Description: Similar to the 302 status code, 307 indicates that the requested resource is temporarily located at a different URI. However, unlike 302, it does not allow changing the HTTP method from POST to GET.

  • Example: If "www.example.com/oldpage" is temporarily moved, and the server wants to ensure the request method remains the same, it will return a 307 status code.


13. Error 200 (OK)

  • Description: The request has succeeded. The server has successfully processed the request, and the resource is returned in the response.

  • Example: Accessing "www.example.com/home" and successfully loading the homepage without any issues will return a 200 status code.


Are there Error 300, and Error 303 - 306?

HTTP status codes are standardized responses provided by web servers to indicate the result of a client's request. While many people are familiar with common status codes like 404 (Not Found) and 500 (Internal Server Error), several other codes are less frequently discussed.


HTTP status codes like 300, 303, 304, 305, and 306 are less commonly encountered than others, they play specific roles in managing how clients and servers interact. Here, we will cover the HTTP status codes 300, 303, 304, 305, and 306.


300 Multiple Choices

  • Description: It indicates that the requested resource has multiple available options, and the user or user agent can select one. This could mean different format options for a resource, different endpoints, or different languages.

  • Usage: It is rarely used in practice because it requires the client to make a decision on which version of the resource to use.


303 See Other

  • Description: This code indicates that the response to the request can be found under a different URI, and the client should use a GET method to retrieve the resource. It is often used to redirect after a PUT or POST operation.

  • Usage: Commonly used in web applications to redirect to another page after form submissions.


304 Not Modified

  • Description: This status code is returned if the resource has not been modified since the last request. This allows for efficient caching, as it tells the client that the stored version is still valid.

  • Usage: Widely used for caching purposes to reduce bandwidth and load times


305 Use Proxy (Deprecated)

  • Description: This code indicates that the requested resource must be accessed through the proxy specified in the response.

  • Usage: It is deprecated due to security concerns and is no longer used in modern web applications.


306 Switch Proxy (No Longer Used)

  • Description: This status code was used in previous versions of HTTP/1.1 but is no longer used. It was intended to indicate that subsequent requests should use the specified proxy.

  • Usage: Reserved for future use; not implemented in modern web servers or clients.


Conclusion

HTTP status codes are a critical part of web communication, indicating the status of a request and helping to diagnose and troubleshoot issues. By understanding these codes, web developers, administrators, and users can better manage and optimize web interactions, ensuring smoother and more reliable web experiences.


For more detailed information, you can refer to resources like the Mozilla Developer Network (MDN) and the IETF documentation.

10 views0 comments

Комментарии


bottom of page