HTTP Status Codes: A Comprehensive Guide
A webpage request is responded to with an HTTP status code. You are basically asking a server to return a document or web page each time you enter a URL, click a link, or receive a search result. A web server will send 3-digit HTTP status codes (such as 200 OK or 404 Not Found) to users, browsers and search engines to inform them of any errors in the request or issues the server may have had processing the request.
When establishing the cause of a website’s problems, such as when a web server is down and not providing pages or when incorrect links have been made on a broken website, HTTP status codes are crucial. Recognizing these problems early on is important.
There are five types or categories for HTTP status codes. The status’s class is indicated by the first number, and each class has unique codes. A descriptive term, such as “OK” or “Moved Permanently,” is typically associated with each unique status code; however, certain servers may offer more descriptive options.
- 1xx categories, respond with information
These status codes don’t actually convey any useful information, despite their name. These indicate that the server is still processing. You are not likely to come across status codes in the 100s. - 2xx categories, accomplishment
The best status possible is success! What you want to see most of the time from your server is the most common response code, 200 OK. The customer is informed that their request was fulfilled and they are getting what they were looking for when they receive a successful response code. - 3xx categories, reroute
These show that the requested page or resource has moved. The updated URL is also sent, and the client automatically requests it after that. You might not even notice the reroute when this occurs in your web browser because it happens so quickly. It’s possible that the URL you click and the one you land on are different. This site uses the status code 301 Moved Permanently the most. - 4xx categories, customer mistake
These codes signal a client error, typically indicating that the client has asked for a resource that is either prohibited or does not exist. The most famous status code is found in this category: 404 Not Found. - 5xx categories, Server error
These numbers indicate that there was a problem with the server or that it is temporarily unavailable for repair.
There are five classes that comprise the HTTP status codes:
- Responses with Information (100–199)
- Successful Response (200–299)
- Redirection Signals (300–399)
- Responses to Client Errors (400–499)
- Responses for Server Errors (500–599)
Responses with Information (100–199)
The request is being handled after it was received.
100 Continue
This normally informs the client that everything is fine to move forward before sending a POST request.
101 Protocols for Switching
The client ought to switch protocols in tandem with the server. When a server moves from HTTP/1.1 to another protocol, such as HTTP/2, which requires a changed syntax for requests and responses, this response is sent.
102 (Deprecated): Processing
The response has not yet been created, but the request is still being processed. This status code means that a request has been received by the server and will be responded to shortly. If the server is still processing a request but hasn’t finished, it can also return a 202 status code.
103 Early Hints
This response code means that although the request has been received, the server is unable to handle it. The server may be busy with other requests or there may be a shortage of resources.
Successful Response (200–299)
The request was successfully processed by the server, and the client is receiving a response.
200 OK
This is the most typical success response, meaning that the request was successfully processed by the server after it was received. A message body containing further details regarding the request’s outcome will also be included by the server.
201 Created
This response code shows that the server got the request, handled it satisfactorily, and produced a new resource. The URL to access the newly added resource will be contained in the location header. An example of the produced resource will be included in the response body.
202 Accepted
This reply code implies that the request was received by the server, which then made the decision to handle it. Nevertheless, there makes no mention of how successful the procedure was. Within the body of the response will be a temporary URL to view a list of the resources that are available. One of the resources can then be selected by the user through a subsequent request.
203 Non-Authoritative Information
This response number indicates that the metadata was retrieved from a local or third-party copy and is not precisely the same as what is available from the origin server. This is primarily utilized for backups or mirrors of other resources. The 200 OK response is recommended over this status, with the exception of that particular instance.
204 No Content
This request is missing any content to be sent, but the headers might be helpful. The user agent might add the updated headers to its cache for this resource.
205 Restore Content
This code instructs the user agent to return the document to its initial state. This is mostly utilized for content that the server has modified, such an HTML form that has been submitted and subsequently removed.
206 Included Content
The server has responded to your request with the response code 206, but it lacks some of the necessary information to complete it. When a request simply requires a subset of the resource to be returned, this is frequently utilized. With the exception of the response body’s incomplete content, this is comparable to 204.
207 Multiple Status
When a client request with numerous arguments is made, the server must deliver many responses. This code is used to handle such requests.
208 Report Already Published
The server has already answered this request, according to this response code. This is frequently used by the server to tell the client not to make the same request after it was performed incorrectly.
Redirection Signals (300–399)
The client needs to take additional steps in order to complete the request, according to this class of status code. An expired URL or a redirect from another server, such as what happens when you look for anything on a search engine, could be the source of this.
300 Multiple-Choice
This code is applied to websites when the user agent or user must select one option out of several available to them. The user agent should show a link in their browser that allows them to select the page they wish to visit when this code is returned.
301 Moved Permanently
When a server has relocated permanently, this code is utilized. In the event that the server responds to this, user agents should no longer bookmark or cache the page because its URL has changed.
302 Found Error
When a resource has been momentarily relocated, this code is applied. This implies that if the user agent still needs to finish processing its present state, it may keep making requests for data from this resource in the future.
303 See Other Response
When a user agent should not be allowed to process its present state after being redirected to another resource by the server, this code is used. This implies that in subsequent requests, the server will send a duplicate of every request header that this new resource returns.
304 Not Changed
When the user agent accesses a resource and the server’s contents haven’t changed since the last request, this code is used. This indicates that subsequent requests won’t require you to submit a fresh copy of this resource.
307 Temporary Redirect
This code is used by the server to inform the client that a request has been redirected and that there is a temporary constraint on the new resource’s availability. Additionally, this code can be used in situations where the server has to temporarily reroute all requests for a specific resource (such when it is performing maintenance on that resource).
308 Redirect Permanently
All upcoming requests should be routed to the new resource, as indicated by this code, which the server uses to notify the client that a request has been permanently redirected. Furthermore, URI of the newly added resource may be included in the location field value of a location request header field included by the server.
Responses to Client Errors (400–499)
The customer did not comply with a legitimate request. A misconfigured URL or not having authorization to access a file or resource on the server could be the cause of this. This can also happen if a page is relocated or removed, but the client must find out if it hasn’t been updated to reflect these changes (such as old bookmarks).
400 Bad Request
The server cannot or will not process the request (e.g., invalid data) if it thinks there is a client issue. The client should refrain from sending the request until it has been repaired.
401 Not Permitted
The target resource cannot be accessed by the client. For access or authorization, the client could be required to submit credentials (password and username, for example).
402 Requires Payment
The client must make payment in order to use the desired resource. The inability to access it for free or the presence of a paywall may be to blame. User payment is required before the request may be fulfilled. This temporary state is taken into account only if the answer includes a “id” field, which is a field used to identify the payment. This answer is final, and you need to buy the resource before making another request if no such ID was provided.
403 Forbidden Error
The requested resource could not be accessed by the client. This can occur from the user not having the necessary rights to submit this request. It is preferable to not make this request at all than to receive an error response from the server because doing so could result in data loss or corruption.
404 Not Found
A resource that you requested is not available. The most typical HTTP error is this one. Additionally, since this error is generic, there are numerous possible causes for it to arise. It’s possible that the resource you’re looking for has moved or been removed, or that you typed the URL incorrectly.
405 Method is forbidden
The server does not support the http method that you requested. For example, if you attempt to use an HTTP GET request on a POST-only resource, the server will reply with this error.
406 Not Acceptable
The desired format or encoding could not be provided by the resource. It’s crucial to remember that this error may also point to a discrepancy between the requests made by your client and the resources made available by the server. For instance, the server may return this error if you request JSON, but it only supports XML.
407 Needs Proxy Authentication
This error means that in order for you to access the resource, the origin server needs to authenticate you through your proxy. There are various possible causes for this: Proxy servers might not be trusted by the server, or it might not want them to access resources on its behalf. Your proxy is not restricted by any IP address or network that the server might be set up to only permit access from.
408 Request Timeout
This error means that the response was not sent to the server in the allotted amount of time. Many things could be the cause of this: It’s possible that the server is overloaded and isn’t responding as quickly as it should. It’s possible that the network connection between the server and your proxy was lost.
409 Conflict
The 409 Conflict status code is used to indicate when the user may be able to resubmit the request after resolving the conflict and indicates that the request could not be performed because of a conflict with the target resource’s current state.
410 Gone Error
The resource you requested has been permanently removed by the server. This most frequently occurs when a page or other resource is removed from the host server but is still cached by your proxy.
411 Length Required
The server has denied the request with the 411 Length Required status code because it needs the Content-Length header field to be provided.
412 Precondition Failed
A request with a precondition was received by the server, but it was not met. The reason for the server’s inability to satisfy a precondition may have been attributed to an error in the server’s implementation of the precondition, or it could have been caused by the request method or time.
413 Payload Too Large
A request with a payload larger than what the server can handle has been received by the server. This error is frequently encountered during file uploads and may arise from the client providing an excessive number of bytes.
414 URI Too Long
A request URI that is longer than the server can handle has been received by the server.
415 Media Type Not Supported
A request for a media type that the server does not support has been received. This can happen if the client transmits a format that is not supported (for example, trying to upload a JPEG image to a server that only accepts PN
416 Range Not Satisfiable
The request that the server received had an incorrect range header field. This may occur when you download a file larger than the maximum size that is supported or try to upload a file with many ranges but only one of them is valid.
417 Expectation Failed
A request with an incorrect Expect header has been received by the server. This can happen if you try to send the necessary GET / HTTP/1.1 request before using the Expect: 100-continue header.
418 I’m a teapot.
This code is frequently used by servers to reply to requests they would prefer not to process.
423 Locked
There is a resource lock on the server, thus it cannot process the request. This can be a transient issue that can be fixed by trying again later, or it might point to a server issue.
429 Too Many Requests Error
The client has made too many requests in too short a time for the server to handle. This could be the result of client-side software bugs or a sign of a denial-of-service assault. Occasionally, this code is sent together with a Retry-After header that can be used to specify how long to wait before attempting to execute the request again.
431 Too Large Request Header Fields
The request’s header fields are too big; thus the server won’t process it. After the request header fields are made smaller, the request can be resubmitted.
451 Unavailable for Legal Reasons
The user agent asked for a resource that is not allowed to be given, like a government-censored website.
Responses for Server Errors (500–599)
These errors are generated by the server. A database error, which can happen when the database gets corrupted or overloaded, is the most frequent cause. On the server side, malfunctioning hardware or software could also be the source of these issues.
500 Error on the Internal Server
The server has run into a scenario that it is ill-prepared to handle.
501 Not Implemented
The server does not support the request method; hence it cannot be processed. Only GET and HEAD are mandatory methods that servers must provide, so they cannot return this code.
502 Bad Gateway
This error response indicates that the server received an incorrect response while acting as a gateway to obtain the response required to process the request.
503 Service Unavailable
The server is unable to process the request due to a transient overload or scheduled maintenance; this will likely be fixed shortly. The length of the delay, if known, may be included in a relevant Retry-After header parameter.
504 Gateway Timeouts
This indicates that the server was unable to process your request in a timely manner due to uncontrollable technical issues (such as network congestion). Usually, it’s the result of an overloaded network or sluggish answers from outside servers, like Internet service provider or CDN (Content Delivery Network) servers.
505 HTTP Version Not Supported
The server does not support the version of HTTP that was used in the request.
506 Variant Also Negotiates
The selected variant resource is set up to engage in transparent content negotiation itself, making it an improper end point in the negotiation process. This indicates that the server has an internal configuration problem.
507 Limited Storage
The server is unable to store the representation required to correctly finish the request, hence the method could not be applied to the resource.
508 Loop Detected
The request was being processed when the server noticed an infinite loop.
510 Not Extended
The server must grant the request with additional extensions.
511 Requires Network Authentication
This status code indicates that before the client may make any more requests, it needs to authenticate with the server. If the client provides credentials for authentication, they might be able to resolve this issue.
Conclusion
In conclusion, we have now thoroughly examined the context of HTTP status codes, acquiring a comprehensive comprehension of their definitions, useful applications, and pivotal significance in API development and online communication. These codes are essential for facilitating information sharing between clients and servers regarding the status of resources and the results of requests.
The significance of HTTP status codes will only grow as we move closer to a linked digital age. It is imperative that developers and operation teams are familiar with these codes because they are necessary for resolving issues with websites and guaranteeing that websites are user accessible. By becoming proficient with these codes, developers may produce more dependable, user-friendly online apps and offer smooth experiences to people all over the world who use the internet.
In summary, HTTP status codes serve as a fundamental component of the web, directing client-server communication and enabling programmers to create reliable online applications. This information is a first step toward managing APIs and web development in a more knowledgeable and effective manner.