Home System Design Tutorial HTTP Response Codes - A complete guide

HTTP Response Codes – A complete guide

HTTP response codes are the set of responses sent by the server to a client to inform the request was successfully received and the result of the execution(whether success or error) is represented using the HTTP response codes provided.

Example – status code 200, means the request is successful and OK, whereas status code 400 means there is an error in the request from the client-side, etc.

HTTP response codes are primarily divided into five classes/groups:

  1.  1xx: Informational 

    It means the request is received and understood. It is issued temporarily while the request is being processed. It tells the user to wait for the final response.

  2.  2xx: Success 

    It tells a client that its request was successfully received, understood and accepted by the server.

  3.  3xx: Redirection 

    This class of status code tells the client further action must be taken to complete the request. Most of the times these status codes are used in URL redirection.

  4.  4xx: Client Error 

    This class of status code indicates that the error is made from the client-side. It is issued when the request contains bad syntax or cannot be fulfilled.

  5.  5xx: Server Error 

    This class of status codes are issued the request is valid but the server is unable to process the request. It indicates that the problem is from the server’s end.

Let’s talk about important HTTP response status codes in each category

1) 1xx: Informational 

    1. 100 Continue  – It is a temporary response indicating the request, has successfully received by the server and the client should continue the request. It is used for sending a large request body to a server
    2. 101 Switching Protocol – This means the requester has asked the server to switch protocols and the server has agreed.
    3. 102 Processing  – This indicates the server has received the request and is processing it.

2) 2xx: Success

    1.  200 OK  – This is a standard response for successful HTTP requests.
    2.  201 Created  – The request was successfully processed and a new resource is created.
    3.  202 Accepted  – The request has been accepted, but not fully processed yet.
    4.  203 Non-Authoritative Information  – It means the request is received from a third party application and the original server has accepted the request and returned OK to the third party application.
    5.  204 No Content  – The server has successfully processed the request and is not going to return any content for the request. It is used when the responses header is useful.
    6.  205 Reset Content  – This tells the user-agent that the server has successfully received the request(and the server will not send any content) and the user-agent should reset the document which sent this request.
    7.  206 Partial Content  – This tells the server is only sending a part of the actual resource meeting the range specified in the header by the client.

3) 3xx: Redirection

    1.  300 Multiple Choices  – It represents multiple resource options for user-agent(client) to choose from. For example, it can be used to present multiple video format options, and the client can choose anyone.
    2.  301 Moved Permanently  – The requested resource has moved to a different location. The response is the new location where the resource is moved.
    3.  302 Found  – It represents the resource of the request that has been changed temporarily to a different location, but the future request should be made to the current location only.
    4.  303 See Other  – This response tells the client to get the resource form a different location using the GET request method.
    5.  304 Not Modified  – It tells a client that the resource has not been modified and there is no need to request again.  When a client stores something in a cache, it also keeps the  Last-Modified header. When a request is made for the same file again, the  If-Modified-Since header is sent to the server. If this value and the server’s ETag value for that file are both the same, the server sends back the  304 Not Modified  HTTP status.
    6.  305 Use Proxy  – (Deprecated) The requested resource can only be accessed using the proxy, the address of which is provided in the response.
    7.  307 Temporary Redirect  – It means the requested resource is temporarily moved to a different location, but the requester should continue to use the original location for future requests. In contrast to 302, in 307 the request method should not change. For instance, a POST request must be repeated using another POST request.
    8.  308 Permanent Redirect  – This means that the resource is permanently moved to a different location(URI), specified by the  Location:  HTTP Response header and all the future requests should be made to the new URI. It also doesn’t allow the HTTP request method to change while requesting the new URI.

4) 4xx Client Error

    1.  400 Bad Request  – The request has invalid syntax and the server cannot process it.
    2.  401 Unauthorized  – The resource requires authentication and the client has failed to do so.
    3.  402 Payment Required  – Reserved for future use.
    4.  403 Forbidden  – The client doesn’t have a right to access the requested resource/page.
    5.  404 Not Found  – The requested resource/page doesn’t exist, but perhaps available in the future
    6.  405 Method Not Allowed  – The HTTP request method is not supported for the requested resource. For example, a GET request on a form that requires data to be presented via POST.
    7.  406 Not Acceptable  – This status is generated when the content generated by the server cannot be accepted by the client.
    8.  407 Proxy Authentication Required  – The client needs to authenticate itself with a proxy.
    9.  408 Request Timeout  – The client did not send any response in a given connection time window and the server timed out waiting for the request.
    10.  409 Conflict  – Indicates that the request could not be processed because there is a conflict in the current state of the resource
    11.  410 Gone  – The requested resource has been permanently deleted from the server with no forwarding address. After receiving 410 status, the client should not request the resource in the future
    12.  411 Length Required  – The server will not accept this request, because the content length is not defined.
    13.  412 Precondition Failed  – The server didn’t meet a precondition mentioned by the client in its header.
    14.  413 Payload Too Large  – The server cannot process the request, because it is larger than what the server can process.
    15.  414 URI Too Long  – The requested URI(generally URL) is larger than what a server is willing to process. It’s is commonly generated when too much data is encoded in a GET request.
    16.  415 Unsupported Media Type  – The server cannot process the request because the media type encoded in the request is not supported by the server.
    17.  425 Too Early  – The server is unwilling to risk processing a request that might be replayed.
    18.  426 Upgrade Required  – The server cannot process the request with the current protocol and the client should switch to the different protocols given in the Upgrade header field.
    19.  429 Too Many Request  – The client sent too many requests in a given time interval. It is generally used to control the rate of requests sent or received.

5) 5xx Server Error 

    1.  500 Internal Server Error  – A generic error message, used when the server encountered an unexpected condition and no more specific message is suitable.
    2.  501 Not Implemented  – The server cannot either handle the request method or it doesn’t recognize the request method.
    3.  502 Bad Gateway  – It means the server while acting as a gateway or proxy, received an invalid response from the upstream server
    4.  503 Service Unavailable  – It means currently the server is not ready to handle the request, because either it is overloaded or down for maintenance. Generally, it is a temporary state.
    5.  504 Gateway Timeout  – This means the server is acting as a gateway and cannot get a response in time from the upstream server.
    6.  505 HTTP Version Not Supported  – The server doesn’t support the HTTP version used in the request.
    7.  507 Insufficient Storage  – The server cannot process a request, because it is unable to store the representation needed to complete the request.
    8.  508 Loop Detected  – The server detected an infinite loop while processing the request.

Did, we miss something or do you want to add some other key points?🤔
Please comment. 😊

Subscribe to our weekly newsletter

Join our community of 1000+ developers and stay updated with the fast moving world of computer science

We promise, we won't spam
Even we hate spam as much as you hate them

LEAVE A REPLY

Please enter your comment!
Please enter your name here