Html Httpmessages
# Understanding HTTP Status Messages
When a web browser (client) requests a page or service from a web server, the server responds with a status code and a corresponding status message. These HTTP status messages indicate whether a specific HTTP request has been successfully completed, redirected, or if an error has occurred on either the client or server side.
This reference guide provides a comprehensive list of HTTP status codes, categorized by their functional groups, to help you debug and optimize your web applications.
---
## HTTP Status Code Categories
HTTP status codes are three-digit integers divided into five distinct classes. The first digit of the status code defines the class of response:
* **`1xx` (Informational):** The request was received, and the process is continuing.
* **`2xx` (Successful):** The action was successfully received, understood, and accepted.
* **`3xx` (Redirection):** Further action must be taken in order to complete the request.
* **`4xx` (Client Error):** The request contains bad syntax or cannot be fulfilled.
* **`5xx` (Server Error):** The server failed to fulfill an apparently valid request.
---
## 1xx: Informational Responses
These status codes indicate a provisional response. The client should continue with its request or ignore the response if it is already finished.
| Status Code & Message | Description |
| :--- | :--- |
| **100 Continue** | The server has received the request headers, and the client should proceed to send the request body (in the case of a request for which a body needs to be sent; for example, a POST request). |
| **101 Switching Protocols** | The requester has asked the server to switch protocols and the server has agreed to do so. |
| **103 Checkpoint** | Used in the resumable requests proposal to resume aborted PUT or POST requests. |
---
## 2xx: Success Responses
These status codes indicate that the client's request was successfully received, understood, and accepted by the server.
| Status Code & Message | Description |
| :--- | :--- |
| **200 OK** | The standard response for successful HTTP requests. The actual response will depend on the request method used. |
| **201 Created** | The request has been fulfilled, resulting in the creation of a new resource. |
| **202 Accepted** | The request has been accepted for processing, but the processing has not been completed. |
| **203 Non-Authoritative Information** | The server successfully processed the request, but is returning information that may be from another source (a cached copy). |
| **204 No Content** | The server successfully processed the request, but is not returning any content. The browser should keep its current page view. This is useful for background tasks or analytics tracking. |
| **205 Reset Content** | The server successfully processed the request, but is not returning any content. Unlike a 204 response, this requires the requester to reset the document view (e.g., clear a form). |
| **206 Partial Content** | The server is delivering only part of the resource (range transmission) due to a range header sent by the client. |
---
## 3xx: Redirection Responses
These status codes indicate that the user agent needs to take further action to complete the request, usually by redirecting to a different URL.
| Status Code & Message | Description |
| :--- | :--- |
| **300 Multiple Choices** | Indicates multiple options for the resource from which the client may choose (up to a maximum of five addresses). |
| **301 Moved Permanently** | This and all future requests should be directed to the given URI. |
| **302 Found** | The requested resource resides temporarily under a different URI. |
| **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 request headers `If-Modified-Since` or `If-None-Match`. The client can use its cached version. |
| **305 Use Proxy** | The requested resource must be accessed through the proxy specified in the `Location` header. |
| **306 Switch Proxy** | *No longer used.* This code was intended to signal that subsequent requests should use the specified proxy. |
| **307 Temporary Redirect** | The requested resource resides temporarily under a different URI. Unlike 302, the request method must not be changed (e.g., a POST must remain a POST). |
| **308 Resume Incomplete** | Used in the resumable requests proposal to resume aborted PUT or POST requests. |
---
## 4xx: Client Error Responses
These status codes indicate that there was an error with the request, often due to client-side issues such as incorrect syntax, missing authentication, or requesting a non-existent resource.
| Status Code & Message | Description |
| :--- | :--- |
| **400 Bad Request** | The server cannot or will not process the request due to an apparent client error (e.g., malformed request syntax). |
| **401 Unauthorized** | Similar to *403 Forbidden*, but specifically for use when authentication is required and has failed or has not yet been provided. |
| **402 Payment Required** | Reserved for future use. The original intention was that this code might be used as part of some form of digital cash or micro-payment scheme. |
| **403 Forbidden** | The request was valid, but the server is refusing action. The user might not have the necessary permissions for a resource. |
| **404 Not Found** | The requested resource could not be found but may be available in the future. Subsequent requests by the client are permissible. |
| **405 Method Not Allowed** | A request method is not supported for the requested resource (e.g., trying to POST to a read-only static page). |
| **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 current state of the resource (e.g., edit conflicts). |
| **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. |
| **413 Request Entity Too Large** | The request is larger than the server is willing or able to process. |
| **414 Request-URI Too Long** | The URI provided was too long for the server to process. This often happens when a POST request is converted to a GET request with long query parameters. |
| **415 Unsupported Media Type** | The request entity has a media type which the server or resource does not support. |
| **416 Requested Range Not Satisfiable** | The client has asked for a portion of the file (Page/Byte Range), but the server cannot provide that portion. |
| **417 Expectation Failed** | The server cannot meet the requirements of the Expect request-header field. |
---
## 5xx: Server Error Responses
These status codes indicate that the server is aware it has erred or is incapable of performing the request.
| Status Code & Message | Description |
| :--- | :--- |
| **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 fulfill the request. |
| **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 cannot handle the request (because it is 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. |
| **505 HTTP Version Not Supported** | The server does not support the HTTP protocol version used in the request. |
| **511 Network Authentication Required** | The client needs to authenticate to gain network access (e.g., accepting terms and conditions on a public Wi-Fi hotspot). |
---
## Developer Considerations
When building web applications, APIs, or configuring web servers, keep the following best practices in mind:
### 1. Use the Correct Status Code
Always return the most accurate status code possible. For example, do not return a `200 OK` with an error message in the JSON body when a resource is not found; return a `404 Not Found` instead. This allows client-side libraries, search engines, and CDN caches to handle the response correctly.
### 2. Handle Redirections Carefully
* Use **`301 Moved Permanently`** for permanent URL changes. This tells search engines to transfer SEO link equity to the new URL.
* Use **`302 Found`** or **`307 Temporary Redirect`** for temporary changes, ensuring search engines do not index the temporary destination in place of the original.
### 3. Graceful Error Handling
When returning `4xx` or `5xx` errors, provide a user-friendly error page or a clear JSON error payload for APIs:
```json
{
"status": 404,
"error": "Not Found",
"message": "The requested user profile with ID 98234 does not exist."
}
```
YouTip