what are http status codes?
Http status code is a code returned by the server along with the response content which indicate the result of client requests on server.
The http status codes are sent by server to client in response to the request made by client to server.
It helps client to understand the status of the request and help them decide further action to be taken.
Example: If a client makes are request to server to create user with wrong params, the server will respond with status code 400, Bad request, the server cannot process the request due to a client error. after seeing the error client will understand that there is issue with request params.
Here is the list of commonly used http status codes.
NOTE: There are more status codes, in this article we have included only most commonly used ones.
1xx Informational responses:
- 100 Continue: The server has received the initial part of the request and awaits the remaining part.
- 102 Processing: The server has received and is processing the request, but no response is available yet.
2xx Success:
- 200 OK: The request has succeeded.
- 201 Created: The request has been fulfilled and a new resource has been created.
- 202 Accepted: The request has been accepted for processing but processing has not been completed.
- 204 No Content: The server successfully processed the request but is not returning any content.
3xx Redirection:
- 301 Moved Permanently: The requested resource has been permanently moved to a new location.
- 303 See Other: The response to the request can be found under another URI using a GET method.
- 304 Not Modified: Indicates that the resource has not been modified since the version specified by the request headers.
4xx Client errors:
- 400 Bad Request: The server cannot process the request due to a client error.
- 401 Unauthorised: Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet been provided.
- 402 Payment Required: Reserved for future use.
- 403 Forbidden: The client does not have permission to access the requested resource.
- 404 Not Found: The requested resource could not be found but may be available in the future.
- 405 Method Not Allowed: A request method is not supported for the requested resource.
- 408 Request Timeout: The server timed out waiting for the request.
- 409 Conflict: Indicates that the request could not be processed because of conflict in the current state of the resource, such as an edit conflict between multiple simultaneous updates.
5xx Server errors:
- 500 Internal Server Error: A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.
- 501 Not Implemented: The server either does not recognize the request method or lacks the ability to fulfil the request.
- 502 Bad Gateway: The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.
- 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, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g., HTTP, FTP, LDAP) or some other auxiliary server (e.g., DNS) it needed to access in order to complete the request.