Server response codes image

When communicating through the HTTP protocol, a server is required to respond to a request – for example, a web browser creating a request for a certain webpage (IP address). Servers respond through numeric codes, known as server response codes.

Although these response codes make more sense to those who are often engaged in server-level programming, the codes may still be transmitted to end-users, making them relevant for everyone to understand. Anyone who’s ever used the internet has, no doubt, stumbled across a server response code at some point. One of the most common is the 404 error message, which indicates that a page cannot be found. Some websites have gotten creative with 404 messaging by creating cartoons or jokes on their 404 pages and adding some quick navigation to help users get back to other parts of the site.

How Do Server Response Codes Work?

In the most basic sense, the job of a server response code is to convey messages from a server to a requester – basically whether everything is OK and, if not, what has gone wrong. Most of the time, these messages stay between servers and requesters but certain messages, such as 404, will appear to end users from time to time.

Whenever a user tries to contact or connect to a server, a “handshake” takes place. This means that the two machines (server and requester) recognize one another and connect to execute the requested action – i.e. displaying a web page.

Different Types of Server Response Codes

There are several kinds of server response codes, and these are grouped into 5 general classes. These are informational, success, redirection, client error and server error. In today’s post, we’ll be discussing the most common of these and providing several examples.

100-level Response Codes: Informational

Server response codes that fall under this category are sent to inform the requester that a request has been received and that the process should continue on.

Code 100: Continue

The server received the requested headers and the client can proceed to send the request body.

Code 101: Switching Protocols

The requester has asked the server to switch protocols (for example, from HTTP to HTTPS) and the server is willing to comply. The protocol to switch is defined in the Upgrade message header field in the message sent by the client.

200-level Response Codes: Success

The codes found in this category are used to indicate that the action requested by the client has been received, understood, accepted and processed successfully.

Code 200: Ok

This is the standard response for successful HTTP requests.

Code 201: Created

The request of the client has been fulfilled and a new resource has been created as a result.

Code 202: Accepted

The client’s request has been accepted for processing, but the process hasn’t yet been completed. There are some instances where these requests will not be processed at all because some part of the request may be disallowed when the actual processing takes place.

Code 203: Non-Authoritative Information

The request was successfully processed by the server, but the information being returned may be from another source.

Code 204: No Content

The request was processed by the server, but no content is being returned. This is usually the response to a successful delete request.

Code 205: Reset Content

The server has processed the request successfully, but content isn’t being returned. What sets the 205 response apart from the 204 is that a 205 indicates that the requester needs to reset the document window.

Code 206: Partial Content

The server only delivers a portion of the resource because the client has sent a range header (used by tools like wget to allow the resumption of interrupted downloads or split downloads into multiple, simultaneous streams).

300-level Response Codes: Redirection

The response codes that fall in the 300-level are used to indicate that further action still has to be taken by the user agent for the request to be fulfilled. Most 300-level status codes are used in URL redirection.

Code 300: Multiple Choices

This code indicates several options for resources that a client will be able to follow. For example, this code can be used to present various format options for video and list files with different extensions.

Code 301: Moved Permanently

The requested resource has been assigned a new permanent URI (uniform resource identifier) and that future references to said resource should use one of the URIs being returned.

Code 302: Found

The requested resource is temporarily located under a different URI. There has been some discrepancy in industry practice in terms of standardizing the 302 response code, as some browsers address these codes in different ways.

Code 303: See Other

The resource requested can be found in another URI by using the GET method.

Code 304: Not Modified

This code is used to indicate that the requested resource has yet to be modified since the version specified by the request headers.

Code 305: Use Proxy

The resource requested is only available through a proxy with the proxy’s address provided within the response. For security reasons, both Mozilla and Internet Explorer refuse to handle this response as it is actually intended.

Code 306: (Unused)

The 306 response code is no longer in use, but it originally specified that “Subsequent requests should use the specified proxy.”

Code 307: Temporary Redirect

The requested resource is located under a different URI, but future requests should still be made using the original URI. This is different from a 302 response in that the request method can’t be changed when the original request is reissued.

400-level Response Codes: Client Error

The response codes within the 400-level are meant to indicate instances of client error. These codes, however, may not always actually represent an error on the aprt of the end user, but may also be created by a coding error on the requested site.

Code 400: Bad Request

The server won’t proceed with the existing request because of a client error. This error may be caused by a malformed request syntax, invalid request message framing or deceptive request routing.

Code 401: Unauthorized

A 401 response code indicates that authentication is needed to access the requested material, but that the authentication has either failed or has not been provided.

Code 402: Payment Required

The 402 response code is not actually used currently but is actually reserved for future use. The intention is that this will become a part of digital currency or micropayment schematics, but this has not yet taken place.

Code 403: Forbidden

The request made was valid, but the server is refusing to respond to it. This is different from a 401 error because in this case, authenticating won’t make a difference.

Code 404: Not Found

The resource that was requested cannot be found at the time of the request, but may be available in the future. Further requests by the client are still allowed. This is probably the most common server response code in terms of end user experience.

Code 405: Method Not Allowed

The server received a request for a resource using a method that the resource does not support. For an example, imagine that a form is requesting using GET, but that the form itself only allows requests to be presented using POST.

Code 406: Not Acceptable

The resource can only generate content deemed acceptable based on the Accept headers sent in the original request.

Code 407: Proxy Authentication Required

The client must authenticate itself with the proxy before completing the request.

Code 408: Request Timeout

The server timed out while waiting for the request. Basically, the client didn’t produce a request within the time that the server was allowed to wait for the request. The request may be repeated by the client without modifications at a later time.

Code 409: Conflict

This indicates that the request can’t proceed due to some conflict in the request, such as an edit conflict created by the use of multiple dates.

Code 410: Gone

The resource requested isn’t available anymore and won’t be available again. This is used when a resource has been removed intentionally AND the resource is intended to be purged.

Code 411: Length Required

This code is used when the length of the content wasn’t specified in the request, but that the length of the content is something required by the requested resource.

Code 412: Precondition Failed

The server doesn’t meet the preconditions that requester has placed on the request.

Code 413: Request Entity Too Large

The request is larger than either what the server is capable of processing or willing to process.

Code 414: Request URI Too Long

The URI provided in the request is too long for the server to process.

Code 415: Unsupported Media Type

The request contains a media type which the server (or the resource requested) isn’t supporting. A common example might be a client trying to upload an image saved as an image/svg+xml, but the server requiring a different format for image files.

Code 416: Requested Range Not Satisfiable

The requested portion of a file can’t be supplied by the server. Think of this as a case where the client my request a portion of a file that extends beyond the end of the file.

Code 417: Expectation Failed

The requirements set in the Expect request-header field cannot be met by the server.

500-level Response Codes: Server Error

500-level response codes are used to denote instances where servers fail to fulfill valid requests.

Code 500: Internal Server Error

Some unexpected condition has been encountered by the server, and this condition has prevented it from fulfilling the request.

Code 501: Not Implemented

The 501 code indicates that the server cannot support the functionality necessary to complete the request.

Code 502: Bad Gateway

The server, in a scenario in which it is acting as a gateway or proxy, has received an invalid response from the upstream server it was accessing to fulfill the request.

Code 503: Service Unavailable

The request cannot be handled by the server. This issue can be triggered by temporary overloading of the server or even basic server maintenance.

Code 504: Gateway Timeout

While acting as a gateway or proxy, the server did not receive a timely response from the upstream server specified in the URI. It is also possible that access to an auxiliary server is needed to complete the request, and that this access may not be available.

Code 505: HTTP Version Not Supported

The server does not or will not support the HTTP protocol version being used in the message of the initial request.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>