HTTP Status Codes: A Guide to Status Codes in the Request-Response Cycle

HanHan
3 min read

Definition

HTTP status codes are codes that are generated during the request-response cycle between a client and a server. They indicate the status of the request made by the client and the response provided by the server.

HTTP Status Codes

1xx (Informational): Request received, continuing process

  • 100 Continue: The server has received the request headers and the client should proceed to send the request body.

  • 101 Switching Protocols: The server agrees to switch to the protocol specified in the Upgrade header field.

2xx (Successful): The request was successfully received, understood, and accepted

  • 200 OK: The request was successful and the server has returned the requested data.

  • 201 Created: The request was successful and a new resource has been created.

  • 204 No Content: The request was successful, but there is no response body to return.

  • 206 Partial Content: The server is delivering only a portion of the resource due to a range header sent by the client.

3xx (Redirection): Further action needs to be taken in order to complete the request

  • 301 Moved Permanently: The requested resource has been permanently moved to a new location, and all future requests should be directed to the new location.

  • 302 Found: The requested resource has been temporarily moved to a different location, but future requests may still be directed to the original location.

  • 304 Not Modified: The requested resource has not been modified since the last time it was accessed by the client, and can be retrieved from the client's cache.

  • 307 Temporary Redirect: The requested resource has been temporarily moved to a different location, but future requests should still be directed to the original location.

4xx (Client Error): The request contains bad syntax or cannot be fulfilled by the server

  • 400 Bad Request: The server cannot understand the request due to bad syntax or an invalid request message.

  • 401 Unauthorized: The request requires authentication, and the client must authenticate itself to get the requested response.

  • 403 Forbidden: The server understands the request, but the client is not authorized to access the requested resource.

  • 404 Not Found: The requested resource could not be found on the server.

5xx (Server Error): The server failed to fulfill a valid request

  • 500 Internal Server Error: The server encountered an unexpected condition that prevented it from fulfilling the request.

  • 502 Bad Gateway: The server received an invalid response from a server acting as a gateway or proxy.

  • 503 Service Unavailable: The server is currently unable to handle the request due to a temporary overload or maintenance of the server.

  • 504 Gateway Timeout: The server acting as a gateway or proxy did not receive a timely response from the upstream server.

There are many other status codes in addition to those listed above, but these are the most commonly used ones.

0
Subscribe to my newsletter

Read articles from Han directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Han
Han