The HTTP Status Codes List: Understanding and Using HTTP Status Codes
Every HTTP response comes with a status code that provides valuable information about how the request was processed. An HTTP status code is the first line in an HTTP response, which is sent from a server to the client. Understanding these status codes is essential for troubleshooting and building robust servers.
Status codes are expressed through three-digit numbers accompanied by a short description. The first digit of the number identifies the response group, which falls into five categories:
1xx: Informational response - indicates that the request was received and understood.2xx: Successful response - indicates that the action requested by the client was received, understood, and accepted.3xx: Redirection - indicates that the client must take additional action to complete the request.4xx: Client error - indicates that an error occurred, seemingly caused by the client.5xx: Server error - indicates that an error occurred on the server.
Here is a comprehensive list of useful status codes, excluding technology-specific and rarely used ones.
Informational Responses
| Status code | Description |
|---|---|
| 100 Continue | The server has received the request headers, and the client should proceed to send the request body. To perform a header check, the client must include the Expect: 100-continue header in the initial request. If the client receives an error code such as 403 (Forbidden) or 405 (Method Not Allowed), it should not send the request body. |
| 101 Switching Protocols | The client requested the server to switch protocols, and the server has agreed to do so. |
Successful Responses
| Status code | Description |
|---|---|
| 200 OK | The standard response for successful HTTP requests. |
| 201 Created | Typically a response to a POST request, indicating that the request has been completed, and a new resource has been created. |
| 202 Accepted | The request has been accepted for processing, but there’s no information about the actual processing or its result. |
| 203 Non-Authoritative Information | The original server returned a 200 status code, but a transforming proxy between the client and server modified the payload. |
| 204 No Content | The server successfully processed the request but is not returning any content. |
| 205 Reset Content | The server successfully processed the request but is not returning any content. In addition, the server requires the client to reset its document view. |
| 206 Partial Content | In response to a Range request from the client, the server sends a partial content response. |
Redirection
| Status code | Description |
|---|---|
| 301 Moved Permanently | All future requests should be directed to the given URI. Use this with GET/HEAD requests and 308 Permanent Redirect with other methods. |
| 302 Found | The resource is temporarily moved to a URL specified by the Location header. Use this with GET/HEAD requests and 307 Temporary Redirect with other methods. |
| 303 See Other | After a POST or PUT request, this status code points to the confirmation message in the Location header. It can be accessed using a new GET request. |
| 304 Not Modified | Indicates that the resource has not been modified when the client uses the If-Modified-Since or If-None-Match request headers. |
| 307 Temporary Redirect | Similar to the 302 request, but it does not allow changing the HTTP method. |
| 308 Permanent Redirect | Similar to the 301 request, but it does not allow changing the HTTP method. |
Client Errors
| Status code | Description |
|---|---|
| 400 Bad Request | The server cannot process the request due to a client-generated error. This includes malformed requests or requests that are too large to handle. |
| 401 Unauthorized | Sent when authentication is required, and the client is not authorized. |
| 403 Forbidden | The requested resource is not available for various reasons. Prefer the 401 Unauthorized status code for authentication-related issues. |
| 404 Not Found | The requested resource could not be found. |
| 405 Method Not Allowed | The resource is not accessible via the HTTP method used in the request, but it might be available through another method. |
| 406 Not Acceptable | The client provided an Accept header with values that the server does not support. |
| 407 Proxy Authentication Required | The client must authenticate with a proxy server that sits between the client and server. |
| 408 Request Timeout | The server timed out while waiting for the request. |
| 409 Conflict | Indicates that the request could not be processed due to a conflict in the current state of the resource. This often occurs with simultaneous updates. |
| 410 Gone | The resource is no longer available and will not be available again. Search engines interpret this as a signal to remove the resource from their index. |
| 411 Length Required | The client must include a Content-Length header in the request, and it was missing. |
| 412 Precondition Failed | Returned when the client’s request headers (If-Unmodified-Since or If-None-Match) cannot be satisfied by the server. |
| 413 Payload Too Large | The request is larger than the server can process or handle. |
| 414 URI Too Long | The provided URI is too long for the server to process. |
| 415 Unsupported Media Type | The request entity has a media type that the server or resource does not support. |
| 416 Range Not Satisfiable | The client requested a portion of the file using the Range header, but the server cannot fulfill that request. |
| 417 Expectation Failed | The server cannot meet the expectations specified in the Expect request header. |
| 421 Misdirected Request | The request was directed at a server that cannot produce a response due to connection reuse or other issues. |
| 426 Upgrade Required | The client should switch to a different protocol, as specified in the Upgrade header field. |
| 428 Precondition Required | The server requires the request to include an If-Match header. |
| 429 Too Many Requests | The user has exceeded the limit for the number of requests within a certain timeframe. It is commonly used for rate limiting. |
| 431 Request Header Fields Too Large | The request cannot be fulfilled because one or more headers, or the entire header set, is too large. |
| 451 Unavailable For Legal Reasons | The resource is not available due to legal reasons. |
Server Errors
| Status code | Description |
|---|---|
| 500 Internal Server Error | A generic server error message sent when an unexpected condition was encountered, and a more specific message is not available. |
| 501 Not Implemented | The server does not recognize the request method or lacks the ability to fulfill the request. |
| 502 Bad Gateway | The server, acting as a gateway or proxy, received an invalid response from the upstream server. |
| 503 Service Unavailable | The server is currently temporarily unavailable, often due to being overloaded or undergoing maintenance. |
| 504 Gateway Timeout | The server, 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 specified in the request. |
Understanding HTTP status codes is crucial for building reliable and user-friendly applications. They provide valuable insights into the success or failure of requests and can guide developers in handling different scenarios effectively.
tags: [“HTTP status codes”, “web development”, “server errors”, “client errors”, “informational responses”, “successful responses”, “redirection”]