What are HTTP Status Codes?
HTTP status codes are returned by the server in response to an HTTP request. They indicate whether the request was successful, if there was an error, or if additional action is needed. These codes are divided into five categories:
1. 1xx: Informational #
These codes indicate that the request was received and is being processed.
100 Continue: The server has received the request headers and the client should proceed to send the request body.
2. 2xx: Success #
These codes indicate that the request was successfully received, understood, and accepted.
200 OK: The request was successful, and the server returned the requested data.
HTTP/1.1 200 OK
201 Created: The request was successful, and a new resource was created.
HTTP/1.1 201 Created
Location: /users/1
204 No Content: The request was successful, but there is no content to send in the response.
HTTP/1.1 204 No Content
3. 3xx: Redirection #
These codes indicate that further action is needed to complete the request.
301 Moved Permanently: The requested resource has been moved to a new URL permanently.
HTTP/1.1 301 Moved Permanently
Location: http://new.example.com/users
302 Found: The requested resource is temporarily available at a different URL.
HTTP/1.1 302 Found
Location: http://temporary.example.com/users
4. 4xx: Client Errors #
These codes indicate that the client made an error in the request.
400 Bad Request: The server could not understand the request due to invalid syntax.
HTTP/1.1 400 Bad Request
401 Unauthorized: The client must authenticate itself to get the requested response.
HTTP/1.1 401 Unauthorized
403 Forbidden: The client does not have access rights to the content.
HTTP/1.1 403 Forbidden
404 Not Found: The server cannot find the requested resource.
HTTP/1.1 404 Not Found
405 Method Not Allowed: The request method is known by the server but is not supported by the target resource.
HTTP/1.1 405 Method Not Allowed
5. 5xx: Server Errors #
These codes indicate that 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.
HTTP/1.1 500 Internal Server Error
502 Bad Gateway: The server received an invalid response from the upstream server.
HTTP/1.1 502 Bad Gateway
503 Service Unavailable: The server is not ready to handle the request, often due to maintenance or overload.
HTTP/1.1 503 Service Unavailable
504 Gateway Timeout: The server did not receive a timely response from the upstream server.
HTTP/1.1 504 Gateway Timeout