A Comprehensive Guide to Understanding HTTP Status Codes

Advertisment

Welcome to the world of HTTP (Hypertext Transfer Protocol) status codes! You may have come across these codes before when browsing the internet, but may not have fully understood their meaning. These codes are used to communicate the status of a client’s request to a server, whether it was successful or not, and if any additional actions are required. In this article, we will dive into the different classes of HTTP status codes and their meanings, making it easy for you to understand and use them to troubleshoot and debug any issues with your website or application. So, let’s get started!

Advertisment

HTTP status codes are three-digit numbers that are grouped into five classes: informational, successful, redirection, client error, and server error. Each class is represented by the first digit of the status code. For example, a status code in the 2xx range indicates a successful request, while a code in the 4xx range indicates a client error.

1xx (Informational)

The 1xx class of status codes indicates that the request was received and the server is continuing to process it. This class of status codes is not often used, but one example is the 100 Continue status code, which indicates that the server has received the request headers and the client should proceed to send the request body.

  • 100 Continue: The server has received the request headers and the client should proceed to send the request body.
  • 101 Switching Protocols: The server understands and is willing to comply with the client’s request to change the application protocol being used on this connection.

2xx (Successful)

The 2xx class of status codes indicates that the request was successfully received, understood, and accepted by the server. The most commonly used status code in this class is 200 OK, which indicates that the request was successful and the server has returned the requested information. Other examples include 201 Created, which indicates that the request was successful and the server has created a new resource as a result, and 204 No Content, which indicates that the request was successful, but the server has not returned any content.

  • 200 OK: The request was successful and the server has returned the requested information.
  • 201 Created: The request was successful and the server has created a new resource as a result.
  • 202 Accepted: The request was accepted for processing, but the processing has not been completed.
  • 203 Non-Authoritative Information: The request was successful, but the information returned by the server may be from a third-party source.
  • 204 No Content: The request was successful, but the server has not returned any content.
  • 205 Reset Content: The request was successful, and the server has reset the document view for the client.

3xx (Redirection)

The 3xx class of status codes indicates that the request needs further action to be completed, such as following a redirect. For example, a 301 Moved Permanently status code indicates that the requested resource has been permanently moved to a new location, while a 307 Temporary Redirect status code indicates that the requested resource is temporarily located at a different location.

  • 300 Multiple Choices: The request has multiple options, and the server has provided a list of options for the client to choose from.
  • 301 Moved Permanently: The requested resource has been permanently moved to a new location.
  • 302 Found: The requested resource is temporarily located at a different location.
  • 303 See Other: The request was successful, and the client should redirect to another URL to retrieve the requested information.
  • 304 Not Modified: The requested resource has not been modified since the client last requested it.
  • 305 Use Proxy: The request must be made through a proxy.
  • 307 Temporary Redirect: The requested resource is temporarily located at a different location.

4xx (Client Error)

The 4xx class of status codes indicates that the request contains bad syntax or cannot be fulfilled by the server. The most commonly used status code in this class is 404 Not Found, which indicates that the requested resource could not be found. Other examples include 401 Unauthorized, which indicates that the request requires authentication, and 405 Method Not Allowed, which indicates that the request method (such as GET or POST) is not allowed for the requested resource.

  • 400 Bad Request: The request was invalid or cannot be understood by the server.
  • 401 Unauthorized: The request requires authentication, such as a login and password.
  • 403 Forbidden: The client does not have access to the requested resource.
  • 404 Not Found: The requested resource could not be found.
  • 405 Method Not Allowed: The request method (such as GET or POST) is not allowed for the requested resource.
  • 406 Not Acceptable: The requested resource is not available in a format that the client can accept.
  • 407 Proxy Authentication Required: The client must first authenticate itself with the proxy.
  • 408 Request Timeout: The server timed out waiting for the request.
  • 409 Conflict: The request could not be completed due to a conflict with the current state of the resource.
  • 410 Gone: The requested resource is no longer available and will not be available again.
  • 411 Length Required: The request did not specify the length of its content, which is required by the requested resource.
  • 412 Precondition Failed: The server does not meet one of the preconditions that the client specified in its request.
  • 413 Request Entity Too Large: The request is larger than the server is able to process.
  • 414 Request-URI Too Long: The requested URI (such as a URL) is too long
  • 415 Unsupported Media Type: The request includes a media type that the server does not support.
  • 416 Requested Range Not Satisfiable: The client has requested a portion of the file (byte serving), but the server cannot supply that portion.
  • 417 Expectation Failed: The server cannot meet the requirements of the Expect request-header field.

5xx (Server Error)

The 5xx class of status codes indicates that the server failed to fulfill a valid request. The most commonly used status code in this class is 500 Internal Server Error, which indicates that the server encountered an unexpected condition that prevented it from fulfilling the request. Other examples include 502 Bad Gateway, which indicates that the server received an invalid response from an upstream server, and 503 Service Unavailable, which indicates that the server is currently unable to handle the request due to a temporary overload or maintenance.

Advertisement
  • 500 Internal Server Error: The server encountered an unexpected condition that prevented it from fulfilling the request.
  • 501 Not Implemented: The server does not support the functionality required to fulfill the request.
  • 502 Bad Gateway: The server received an invalid response from an upstream server while attempting to fulfill the request.
  • 503 Service Unavailable: The server is currently unable to handle the request due to a temporary overload or maintenance.
  • 504 Gateway Timeout: The server did not receive a timely response from an upstream server while attempting to fulfill the request.
  • 505 HTTP Version Not Supported: The server does not support the HTTP protocol version that was used in the request.

Conclusion

HTTP status codes provide a way for the server to communicate the outcome of a client’s request. They are divided into five classes: informational, successful, redirection, client error, and server error. Understanding these codes and their meanings can help you troubleshoot and debug issues with your website or application. It’s important to note that these are just a few examples of the many HTTP status codes that exist, and it’s worth noting that these codes are not only used for web pages but also for any kind of resources that are transferred over HTTP.

Advertisment
Leave a Reply
You May Also Like