HTTP Response Codes

By:    Updated: March 1,2017

HTTP Response Codes indicate whether a specific HTTP requests has been successfully completed. Responses are grouped in the following five classes:

Informational responses (1xx) are provisional responses. Most of the time neither the end user, nor the web developer or webmaster should have to bother with these. The most common is the 100 Continue response, indicating that the client should continue to send its request.

Success responses (2xx) are for successfully processed requests. The 200 OK response is by far the most common of these responses, but the 206 Partial Content is also often seen when fetching a file or some media data like video or audio.

Redirection responses (3xx) indicate that the resource that the client requested has moved and the server is not able to serve it directly. Most of these responses contain some location information telling where to find the requested resource; user-agents often then retrieve it without further user interaction. The most common responses of this type are 301 Moved Permanently, indicating that the URI given is no longer valid and has been moved to another place, and 302 Found which indicates that the resource has been temporarily moved to another place.

Client error responses (4xx) indicate that the request sent by the client is either invalid, incomplete, or doesn't have enough rights to be performed. The most common such response is 404 Not Found which is sent back when the URI requested doesn't exist, but a few others are often presented to the end user, like 400 Bad Request sent when the request isn't a valid HTTP request or 403 Forbidden, sent when the client request a resource that does exist but isn't allowed to be transmitted (like a directory content, or need user authentication).

Server error responses (5xx) indicate that the server had a problem handling the valid client request. The two most common such responses are 500 Internal Server Error, a generic error code indicating a bug in the server or 503 Service Unavailable indicating that the server cannot process the request due to a temporary problem, like a disabled service for maintenance purposes or the non-availability of a database.

Response Codes List

The following table lists some of them which often used in the application, with their respective meanings:

Response Code Response Text Description
200 OK The request has succeeded.
301 Moved Permanently The URI of requested resource has been changed.Probably, new URI would be given in the response.
302 Moved Temporarily The URI of requested resource has been changed temporarily. New changes in the URI might be made in the future. Therefore, this same URI should be used by the client in future requests.
304 Not Modified This is used for caching purposes. It is telling to client that response has not been modified. So, client can continue to use same cached version of response.
400 Bad Request The server could not understand the request due to invalid syntax.
401 Unauthorized Authentication is needed to get requested response. This is similar to 403, but in this case, authentication is possible.
403 Forbidden Client does not have access rights to the content so server is rejecting to give proper response.
404 Not Found Server can not find requested resource. This response code probably is most famous one due to its frequency to occur in web.
500 Internal Server Error The server has encountered a situation it doesn't know how to handle.
502 Bad Gateway The server, while working as a gateway to get a
response needed to handle the request, got an invalid response.
503 Service Unavailable The server is not ready to handle the request. Common causes are a server that is down for maintenance or that is overloaded.
504 Gateway Timeout This error response is given when the server is acting as a gateway and cannot get a response in time.

Recommendation

For webmasters, it is recommended to set up a 301 Moved Permanently redirection when moving pages to another URI, during a site reorganization for example. That allows users following links to still reach the resource and it also teaches search engines and other services the new location of the resource, so that they can transfer their metadata to it. It is also important to add adequate cache headers to the 301 Moved Permanently response so that this information is cached by the client and prevents it from making unnecessary requests to the original URI prior to fetching the resource itself.

More in Development Center
New on Valinv
Related Articles
Sponsored Links