HTTP Status Codes
Table of Contents
Beginner - This article is part of a series.
Every time we enter a URL and press Enter or click directly on a link via our keyboard, we are sending an HTTP request to the server from our browser. The server receives this request, processes it, and sends back a response along with this response. This response also includes a status code from the HTTP protocol, which may not be visible but can often be observed in our browsers. HTTP status codes indicate whether an HTTP request has been completed successfully or not. Understanding these codes is crucial when we are performing performance tests. These fall into five classes: informative responses, successful responses, redirects, client errors, and server errors.
(1XX): Informative Responses #
These status codes indicate that the request sent to the server is still in progress. These codes only provide additional information about what is happening between the client and server.
(2XX): Satisfactory Responses #
A response with this range of codes means that everything is functioning as expected.
(3XX): Redirections #
The codes 300s are used to communicate that the resource has moved to a new location. There are several of these status codes accompanying redirects, to provide visitors with information about where they can find the content they are looking for.
(4XX): Client Errors #
These codes are related to errors from the client, specifying that something has failed in your order.
(5XX): Errors from the Server #
These codes are related to errors from the server side.
Here are some examples of these codes.
100s: Informative Responses #
- 100 Continue: This means that the server has received the headers of your browser request and is now ready to send the body of the request.
- 101 Switching Protocols: Your browser has asked the server to switch protocols, and the server has complied.
- 102 Processing: This code indicates that the server has received the request but still needs to process it before any response can be provided.
- 103 Early Response Suggestions: This returns some headers of the response earlier than the rest of the server’s response is ready.
200s : Satisfactory Responses #
- 200 OK: The request has been successful.
- 201 Created: The request has been successful and a new resource has been created, related to the response sent after a PUT request. This code may appear when using a proxy.
- 202 Accepted: The server has accepted the browser’s request but is still processing it. The final result of the request can or cannot be an entirely complete response.
- 203 Unauthorized Information: The request was completed successfully, but its content could not have been obtained from the originally requested source, this code may appear when using a proxy.
- 204 No Content: The request has been successful but no content is returned in the response, although headers can be useful.
- 205 Reset Content: The request was completed successfully, but its response does not have any content and moreover, the user agent must initialize the page from which the request was made, this code is useful for pages with forms whose content should be cleared after the form has been sent, for example.
- 206 Partial Content: This allows a browser to resume paused downloads and divide a download into multiple transmissions. When an encoding range header makes the server send only part of the requested resource, it sends a 206 code.
300s: Redirects #
- 300 Multiple Options: Often, there can be multiple resources that the server could respond to fulfill the request coming from the browser. The status code 300 means that your browser now has to choose between them. This can happen when there are several file types available or if the server is experiencing some aspect related to resolution.
- 301 Moved Permanently: The requested resource has been permanently moved. This code is sent when a web page or resource has been replaced permanently by a different one.
- 302 Resource Found: This code indicates that the resource was found, but not in the location where it was expected. It’s used for temporary URL redirection.
- 303 Other: The requested resource can be found at another URI. The server sends this response to direct the client to a new resource being requested using a GET request.
- 304 Not Modified: This is used for “caching” purposes. It indicates that the response has not been modified and thus, the client can continue using the cached version stored in its cache.
- 307 Temporary Redirect: The server sends this response to direct the client to obtain the requested resource at another URI with the same method as was used in the previous request. Has the same semantic meaning as HTTP status code 302, except that the user agent should not change the HTTP method used.
- 308 Permanent Redirect: Means that the resource is now permanently located at a different URI specified by the “HTTP Location” header. It has the same semantic meaning as HTTP status code 301 with the exception of the fact that the client user agent should not change the HTTP method used.
400s : Client Errors #
- 400 Bad Request: This response indicates that the server could not interpret the request due to an invalid syntax.
- 401 Unauthorized or Requires Authentication: The server returns when the destination resource lacks valid authentication credentials.
- 402 Payment Required: This code is reserved for future use. Initially, its purpose was to be used in digital payment systems. However, it is not being used currently.
- 403 Forbidden: This code is returned when a user attempts to access something that does not have permission to view. For example, trying to reach content protected by password without logging in can produce an error 403.
- 404 Not Found: The server could not find the requested content. This is one of the most famous due to its high occurrence on the web.
- 405 Method Not Allowed: The method requested is known by the server but has been disabled and cannot be used.
- 406 Unsupported Media Type: The resource requested can only generate content that is not acceptable according to the accept headers sent in the request.
- 407 Proxy Authentication Required: A proxy server is being used, and requires a browser to authenticate before continuing.
- 408 Request Timeout: This code is generated when a server exhausts its time waiting for the rest of the request from the browser. In other words, the server did not receive the complete request sent by the browser.
- 409 Conflict: A 409 means that the server could not process the request of your browser because there is a conflict with the relevant resource. This sometimes occurs due to simultaneous edits.
- 410 Gone: This code is similar to a 404 “Not Found”, except that a 410 indicates that the condition is expected and permanent.
500s: Server Errors #
- 501 Not Implemented: This error indicates that the server does not support the functionality required to fulfill the request. This is usually a problem with the web server and, generally, the host should resolve it.
- 502 Bad Gateway: This response means that the server while working as a gateway to obtain a necessary response for handling the request received an invalid response. This code of error generally means that a proxy server has been used.
- 503 Service Unavailable: The server is not ready to handle the request. Common causes can be that the server is down for maintenance or overloaded. It should be noted that with this response, a user-friendly page explaining the problem must be sent.
- 504 Gateway Timeout: This error is given when the server acts as a gateway and cannot obtain an answer in time.
- 505 HTTP Version Not Supported: The version of HTTP used in the request is not supported by the server.
These are not the only codes that exist, many others can be found in this reference I will share below:
- https://www.w3.org/Protocols/
- https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Status