HTTP Status Codes: A Complete Overview

HTTP Status Codes: A Complete Overview

HTTP status codes are three-digit numerical codes returned by servers in response to client requests. They provide crucial information about the status of the request and indicate whether it was successful, encountered an error, or requires further action. Understanding these codes is essential for web developers, system administrators, and anyone working with web technologies. This comprehensive overview will delve into the different classes of status codes, explore the most common codes encountered, and provide detailed explanations of their meaning and implications.

Understanding Status Code Classes

HTTP status codes are grouped into five classes, each represented by the first digit of the code:

  • 1xx (Informational): These codes indicate that the request was received and is being processed. They are rarely seen by the end-user.
  • 2xx (Successful): These codes signify that the request was successfully received, understood, and accepted.
  • 3xx (Redirection): These codes indicate that further action needs to be taken by the client in order to complete the request. This usually involves following a redirect to a different URL.
  • 4xx (Client Error): These codes represent errors that originated from the client side, such as a malformed request or unauthorized access.
  • 5xx (Server Error): These codes indicate errors on the server side that prevented it from fulfilling the request.

Detailed Explanation of Common Status Codes

Below is a detailed breakdown of frequently encountered HTTP status codes within each class:

1xx Informational:

  • 100 Continue: The server has received the request headers and the client should proceed to send the request body.
  • 101 Switching Protocols: The server agrees to switch protocols as requested by the client.
  • 102 Processing (WebDAV): Indicates that the server has received and is processing a long request and will respond later.
  • 103 Early Hints: Sent before a final response to allow the client to begin pre-loading resources.

2xx Success:

  • 200 OK: The request was successful. The meaning of “success” depends on the HTTP method used:
    • GET: The resource has been fetched and is transmitted in the message body.
    • HEAD: The entity headers are in the message body.
    • POST: The resource describing the result of the action is transmitted in the message body.
    • PUT: The resource has been updated.
    • DELETE: The resource has been deleted.
  • 201 Created: The request has been fulfilled and resulted in a new resource being created.
  • 202 Accepted: The request has been accepted for processing, but the processing has not been completed.
  • 203 Non-Authoritative Information: The server is a transforming proxy (e.g., a Web accelerator) that received a 200 OK from its origin, but is returning a modified version of the origin server’s response.
  • 204 No Content: The server successfully processed the request and is not returning any content.
  • 205 Reset Content: The server successfully processed the request, asks that the requester reset the document view, and is not returning any content.
  • 206 Partial Content: The server is delivering only part of the resource due to a range header sent by the client.
  • 207 Multi-Status (WebDAV): Provides status for multiple independent operations.
  • 208 Already Reported (WebDAV): The members of a DAV binding have already been enumerated in a preceding part of the (multistatus) response, and are not being included again.
  • 226 IM Used: The server has fulfilled a request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance.

3xx Redirection:

  • 300 Multiple Choices: Indicates multiple options for the resource from which the client may choose.
  • 301 Moved Permanently: The resource has permanently moved to a new URL. Clients should update their bookmarks and links.
  • 302 Found (Previously “Moved Temporarily”): The resource has temporarily moved to a new URL. Clients should continue to use the original URL for future requests.
  • 303 See Other: The response to the request can be found under another URI using a GET method.
  • 304 Not Modified: Indicates that the resource has not been modified since the version specified by the client in the If-Modified-Since or If-None-Match headers.
  • 307 Temporary Redirect: The resource has temporarily moved to a new URL. Similar to 302 but preserves the request method.
  • 308 Permanent Redirect: The resource has permanently moved to a new URL. Similar to 301 but preserves the request method.

4xx Client Error:

  • 400 Bad Request: The server cannot or will not process the request due to an apparent client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
  • 401 Unauthorized: Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet been provided.
  • 403 Forbidden: The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client’s identity is known to the server.
  • 404 Not Found: The server can not find the requested resource.
  • 405 Method Not Allowed: The request method is known by the server but has been disabled and cannot be used.
  • 406 Not Acceptable: The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request.
  • 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: Indicates that the request could not be processed because of conflict in the request, such as an edit conflict between multiple simultaneous updates.
  • 410 Gone: Indicates that the resource requested 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 requester put on the request header fields.
  • 413 Payload Too Large (previously “Request Entity Too Large”): The request is larger than the server is willing or able to process.
  • 414 URI Too Long (previously “Request-URI Too Long”): The URI provided was too long for the server to process.
  • 415 Unsupported Media Type: The request entity has a media type which the server or resource does not support.
  • 416 Range Not Satisfiable: The client has asked for a portion of the file (byte serving), but the server cannot supply that portion. For example, if the client asked for a part of the file that lies beyond the end of the file.
  • 417 Expectation Failed: The server cannot meet the requirements of the Expect request-header field.
  • 421 Misdirected Request: The request was directed at a server that is not able to produce a response. This can be caused by a client that is sending the request to the wrong server.
  • 422 Unprocessable Entity (WebDAV): The request was well-formed but was unable to be followed due to semantic errors.
  • 423 Locked (WebDAV): The resource that is being accessed is locked.
  • 424 Failed Dependency (WebDAV): The request failed due to failure of a previous request (e.g., a PROPPATCH).
  • 425 Too Early: Indicates that the server is unwilling to risk processing a request that might be replayed.
  • 426 Upgrade Required: The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field.
  • 428 Precondition Required: The origin server requires the request to be conditional. Intended to prevent “the lost update” problem, where a client GETs a resource’s state, modifies it, and PUTs it back to the server, when meanwhile a third party has modified the state on the server, leading to a conflict.
  • 429 Too Many Requests: The user has sent too many requests in a given amount of time (“rate limiting”).
  • 431 Request Header Fields Too Large: The server is unwilling to process the request because either an individual header field, or all the header fields collectively, are too large.
  • 451 Unavailable For Legal Reasons: A server operator has received a legal demand to deny access to a resource or to a set of resources that includes the requested resource.

5xx Server Error:

  • 500 Internal Server Error: A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.
  • 501 Not Implemented: The server either does not recognize the request method, or it lacks the ability to fulfil the request. Usually this implies future availability (e.g., a new feature of a web-service API).
  • 502 Bad Gateway: The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.
  • 503 Service Unavailable: The server is currently unavailable (e.g., overloaded or down for maintenance). Generally, this is a temporary state.
  • 504 Gateway Timeout: The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g., HTTP, FTP, LDAP) or some other auxiliary server (e.g., DNS) it needed to access in attempting to complete the request.
  • 505 HTTP Version Not Supported: The server does not support the HTTP protocol version used in the request.
  • 506 Variant Also Negotiates (RFC 2295): Transparent content negotiation for the request results in a circular reference.
  • 507 Insufficient Storage (WebDAV): The server is unable to store the representation needed to complete the request.
  • 508 Loop Detected (WebDAV): The server detected an infinite loop while processing the request (sent in lieu of 208 Already Reported).
  • 510 Not Extended: Further extensions to the request are required for the server to fulfill it.
  • 511 Network Authentication Required: The client needs to authenticate to gain network access. Intended for use by intercepting proxies used to control access to the network (e.g., “captive portals” used to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).

This comprehensive overview of HTTP status codes provides a foundation for understanding server responses and troubleshooting web applications. Familiarizing yourself with these codes will greatly enhance your ability to diagnose issues and ensure seamless communication between clients and servers. Remember to consult the official HTTP specifications for the most accurate and up-to-date information.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top