HTTP Status Codes: Understanding the Meaning Behind Them
When you browse the internet, you may have seen various numbers pop up when a webpage fails to load or when an error occurs. These numbers, known as HTTP status codes, are an essential part of the internet and provide valuable information to users and web developers alike. In this article, we will delve into HTTP status codes and what they mean.
What are HTTP Status Codes?
HTTP status codes are three-digit numbers that indicate the status of a request made by a client (such as a web browser) to a server (such as a web server). They are part of the Hypertext Transfer Protocol (HTTP) used to communicate between web servers and web browsers.
The first digit of the status code defines the class of response that the server is sending to the client.
There are five classes of status codes, as shown in the table below:
Class | Description |
---|---|
1xx | Informational responses |
2xx | Successful responses |
3xx | Redirection messages |
4xx | Client errors |
5xx | Server errors |
Informational responses (1xx) provide information about the status of the request and are mainly used for debugging purposes. Successful responses (2xx) indicate that the request was successful and the server is sending the requested content. Redirection messages (3xx) indicate that the requested resource has moved or is temporarily unavailable, and the client should redirect the request to another URL. Client errors (4xx) indicate that there is an error with the request made by the client, such as an incorrect URL or invalid parameters. Server errors (5xx) indicate that the server encountered an error while processing the request.
Each class of status codes has a specific meaning, as shown in the table below:
Code | Meaning |
---|---|
100 | Continue |
101 | Switching Protocols |
200 | OK |
201 | Created |
202 | Accepted |
203 | Non-Authoritative Information |
204 | No Content |
205 | Reset Content |
206 | Partial Content |
300 | Multiple Choices |
301 | Moved Permanently |
302 | Found |
303 | See Other |
304 | Not Modified |
305 | Use Proxy |
307 | Temporary Redirect |
400 | Bad Request |
401 | Unauthorized |
402 | Payment Required |
403 | Forbidden |
404 | Not Found |
405 | Method Not Allowed |
406 | Not Acceptable |
407 | Proxy Authentication Required |
408 | Request Timeout |
409 | Conflict |
410 | Gone |
411 | Length Required |
412 | Precondition Failed |
413 | Request Entity Too Large |
414 | Request-URI Too Long |
415 | Unsupported Media Type |
416 | Requested Range Not Satisfiable |
417 | Expectation Failed |
500 | Internal Server Error |
501 | Not Implemented |
502 | Bad Gateway |
503 | Service Unavailable |
504 | Gateway Timeout |
505 | HTTP Version Not Supported |
Ten interesting and unique facts about HTTP status codes:
- The 201 status code, “Created,” is used to indicate that a new resource has been successfully created on the server.
- The 204 status code, “No Content,” is used to indicate that the server has successfully processed a request but has no content to return.
- The 402 status code, “Payment Required,” is reserved for future use and was originally intended for a digital cash payment system that never came to fruition.
- The 410 status code, “Gone,” is used to indicate that a resource on the server is no longer available and will not be coming back.
- The 429 status code, “Too Many Requests,” is used to indicate that the user has sent too many requests in a given amount of time and has exceeded the server’s rate limit.
- The 503 status code, “Service Unavailable,” is used to indicate that the server is temporarily unavailable, often due to maintenance or high traffic.
- The 504 status code, “Gateway Timeout,” is used to indicate that a server acting as a gateway or proxy has not received a timely response from the upstream server.
- The 101 status code, “Switching Protocols,” is used to indicate that the server is switching to a different protocol, such as from HTTP to WebSocket.
- The 206 status code, “Partial Content,” is used to indicate that the server is sending only a part of the requested resource, typically in response to a request for a large file.
- The 308 status code, “Permanent Redirect,” was introduced in 2014 to replace the 301 status code in cases where the redirect is intended to be permanent, rather than temporary.
- The HTTP status code 418, “I’m a teapot,” was actually a joke created by the author of the HTTP/1.1 specification, which was later adopted by some websites as an Easter egg.
- The HTTP status code 511, “Network Authentication Required,” was introduced to support proxy servers that require authentication, making it possible to authenticate a client request with a server.
- The HTTP status code 451, “Unavailable for Legal Reasons,” was created to indicate that a resource has been removed or blocked for legal reasons, such as a court order or government censorship.
HTTP status codes are an important part of the internet and are used by web servers and clients to communicate with each other. Understanding their meanings and uses can help website owners and developers improve the performance and user experience of their websites.