HTML error codes are just as familiar to web developers as the tech-phobic. The only real difference is that web developers are supposed to know what they mean!
Of course, any developer knows the most common: 404 means the page isn’t there; 503 means the server is overloaded; 403 means “forbidden,” which is somehow different from 501 Unauthorized. If you understand these status codes more completely, you can build a better picture of how HTTP works and what you can do with it.
Informational Codes (1xx)
These status codes provide instructions for the user agent. They tell the client what to do next.
The client should continue with the request. This code is sent to indicate that the server has received and accepted the message so far, and that it is ready to receive the remainder of the message. If the status message arrives after the transfer is complete, this response can be ignored.
101 Switching Protocols
Sent after the client requests a protocol change. The server can and will comply with the protocol requested in the message from the client.
Success Codes (2xx)
Like the name suggests, these codes indicate success. They’re sent when the server receives, understands, and accepts the message.
The request has succeeded. Alongside this status code, you can receive a variety of responses depending on how the request was made.
- GET: The requested resource is in the message body.
- HEAD: The headers are in the message body.
- POST: A message with the result of the action is contained in the message body.
- TRACE: The message body contains the request as received by the server.
The request to create and serve a new resource has been received and accepted. Typically, this is seen in response to POST requests.
The message has been received and accepted, but the server has not yet acted upon in. This is intended for situations where requests are processed by another application or server.
203 Non-Authoritative Information
The meta-information contained in the header of the message is not the definitive version from the server. Instead, it’s collected from a third-party or a local resource, meaning it might be out-of-date with the server’s actual copy.
204 No Content/No Response
Headers are sent, but there is no content to fulfill the client’s request. This code is sent when the headers might be informative but the content is not available.
205 Reset Content
The request has been fulfilled, and the server asks the user agent to reset the document view to accommodate it. This can be useful for clearing input areas so that new content can be added.
206 Partial Content
The client’s GET request is only partially fulfilled. The response includes a range in the header field to indicate what part of the request has been fulfilled.
Redirect Codes (3xx)
These codes indicate that the requested resource was replaced with a redirection message.
300 Multiple Choices
There are multiple versions of the requested resource. The user or browser must select the resource they want.
301 Moved Permanently
The requested resource has been moved to a new location permanently. Future requests for this content should use the updated URI. If a resource is permanently moved, this should be the status code the server reports. For SEO, a 301 redirection also transfers all the original URL’s equity, preserving the URI’s Google juice.
The requested resource is under a different URI, but only temporarily. This status code does not pass along equity, meaning the new, temporary URI doesn’t have the Google juice of the original URI.
303 See Other
The received GET request should instead be sent a different URI. This allows a POST-activated script, like a form’s submit button, to redirect the user to the correct resource.
304 Not Modified
This message confirms that the cached version of the resource and the server’s authoritative version of the resource has not been modified.
307 Temporary Redirect
The same semantics as a 302 Found redirect, with the additional restriction that the user agent must not change the HTTP method used.
308 Permanent Redirect
The same semantics as 301 Moved Permanently, with the additional restriction that the user agent must not change the HTTP method used.
Error Codes (4xx)
Everyone’s favorite class of status codes, the 400s. These status codes indicate that something has gone wrong with the client’s request or the server’s resource.
400 Bad Request
The request was malformed or corrupted in some way.
The user agent must be authenticated to receive the requested resource.
The user agent does not have access rights for the requested resource. Unlike 401 Unauthorized, the identity of the user agent has been authenticated, but that user does not have access rights.
404 Not Found
The URI provided does not lead to a valid resource on the server.
405 Method Not Allowed
The client’s HTTP method is not permitted on this resource. For example, the client can’t use DELETE messages to remove content from the server.
406 Not Acceptable
During server-side content negotiation, the client’s message did not contain the required contents.
407 Proxy Authentication Required
Like 401 Unauthorized, but directs the client to a proxy server to perform authentication.
408 Request Timeout
The server has been waiting for a response from the client, but did not receive one in the desired time interval and would now like to close the connection.
The request conflicts with the current state of the server. This code should only be used when the user could resolve the conflict.
The requested resource was removed from this URI, and its present location is unknown. This code is different from 404, indicating that the site’s maintainers intentionally removed the requested resource and the URI will not become valid again.
411 Length Required
The server requires the Content-Length head field, but the client did not provide it.
412 Precondition Failed
The server did not meet the client’s specified preconditions.
413 Request Entity Too Large
The requested entity is larger than the limits defined by the server.
414 Request-URI Too Long
The URI sent by the client is longer than the server’s limits.
416 Requested Range Not Satisfiable
The client’s request in the Range header field cannot be fulfilled. The range might be invalid, or extend outside the size of the target URI’s data.
417 Expectation Failed
The expectation indicated in the Expect request header field was not met.
Server-side Error (5xx)
These status codes all indicate that some error has occurred on the server. While 400-class error messages can be fixed by altering the client’s request, 500-class error messages can typically only be addressed by the server’s administrator.
500 Internal Server Error
The server reports an unspecified error.
501 Not Implemented
The HTTP request method is not implemented on the server. GET and HEAD are the only HTTP method’s that must be supported by the server.
502 Bad Gateway
While acting as a gateway or proxy, the server received an invalid response.
503 Service Unavailable
The server cannot currently handle the client’s request. This typically occurs when the server’s traffic suddenly increases, like when a small site is featured in a popular social media post. This may include instructions on when the client can try again.
504 Gateway Timeout
While acting as a gateway or proxy, the server did not receive a response within the specified time limits.
505 HTTP Version Not Supported
The requested HTTP version is not supported. This response should include a description of why the version is not supported and what protocols are supported by the server.
511 Network Authentication Required
This response indicates that the user agent must authenticate to gain network access. The response should contain a link to the resource that manages the authentication process.
You might be surprised to learn that this isn’t even all the error codes. It’s just the most common ones. If you want to see an exhaustive list of status codes, which is too long to publish here, you can check out MDN’s HTTP status code documentation.
You might also like the following posts:
32 Creative and Funny Error Pages
The Top 3 Server Problems to Watch For
Why Web Devs Need To Know About Servers And Infrastructure In 2018
The post Decoding HTML Status and Error Codes For Fun and Profit appeared first on SpyreStudios.