HTTP Status Codes Cheatsheet
22 most frequently used HTTP status codes that developers should know
In this blog post, I will mention about 22 most frequently used HTTP Status Codes. I Often google it for few HTTP status codes, so I thought it will be useful to create a cheatsheet to refer most frequently used status codes.
- Successful Responses
- Redirection Messages
- Client Error Responses
- Server error responses
1. Successful Responses
- 200 OK
The request has succeeded. The meaning of the success depends on the HTTP method:
GET: The resource has been fetched and is transmitted in the message body.
HEAD: The representation headers are included in the response without any message body.
PUT or POST: The resource describing the result of the action is transmitted in the message body.
TRACE: The message body contains the request message as received by the server.
- 201 Created
The request has succeeded and a new resource has been created as a result. This is typically the response sent after POST requests or some PUT requests.
- 204 No Content
There is no content to send for this request, but the headers may be useful. The user-agent may update its cached headers for this resource with the new ones.
2. Redirection Messages
- 301 Moved Permanently
The URL of the requested resource has been changed permanently. The new URL is given in the response.
- 302 Found
This response code means that the URI of the requested resource has been changed temporarily. Further changes in the URI might be made in the future. Therefore, this same URI should be used by the client in future requests.
- 307 Temporary Redirect
The server sends this response to direct the client to get the requested resource at another URI with the same method that was used in the prior request. This has the same semantics as the 302 Found HTTP response code, with the exception that the user agent must not change the HTTP method used: If a POST was used in the first request, a POST must be used in the second request.
- 308 Permanent Redirect
This means that the resource is now permanently located at another URI, specified by the Location: HTTP Response header. This has the same semantics as the 301 Moved Permanently HTTP response code, with the exception that the user agent must not change the HTTP method used: If a POST was used in the first request, a POST must be used in the second request.
3. Client Error Responses
- 400 Bad Request
The server could not understand the request due to invalid syntax.
- 401 Unauthorized
Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response.
- 403 Forbidden
The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401, the client's identity is known to the server.
- 404 Not Found
The server can not find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 to hide the existence of a resource from an unauthorized client. This response code is probably the most famous one due to its frequent occurrence on the web.
- 405 Method Not Allowed
The request method is known by the server but has been disabled and cannot be used. For example, an API may forbid DELETE-ing a resource. The two mandatory methods, GET and HEAD, must never be disabled and should not return this error code.
- 408 Request Timeout
This response is sent on an idle connection by some servers, even without any previous request by the client. It means that the server would like to shut down this unused connection.
- 413 Payload Too Large
Request entity is larger than limits defined by server; the server might close the connection or return a Retry-After header field.
- 414 URI Too Long
The URI requested by the client is longer than the server is willing to interpret.
- 415 Unsupported Media Type
The media format of the requested data is not supported by the server, so the server is rejecting the request.
- 422 Unprocessable Entity
The request was well-formed but was unable to be followed due to semantic errors.
- 429 Too Many Requests
The user has sent too many requests in a given amount of time ("rate limiting").
4. Server error responses
- 500 Internal Server Error
The server has encountered a situation it doesn't know how to handle.
- 502 Bad Gateway
This error response means that 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. Note that together with this response, a user-friendly page explaining the problem should be sent.
- 504 Gateway Timeout
This error response is given when the server is acting as a gateway and cannot get a response in time.
Thank you for reading
Hope you find these resources useful. If you like what you read and want to see more about system design, microservices, and other technology-related stuff... You can follow me on
Twitter - Follow @vishnuchi
Subscribe to my weekly newsletter here.
Technology and startup enthusiastic. Learning to lead optimised life. I write about system design, databases, microservices, backend development, developer tools, life sciences & books I read 😀