HTTP (HyperText Transfer Protocol) status codes are three-digit responses that a server sends to a client (such as a web browser) following an HTTP request. These codes provide information about the status of the request, indicating whether it was successful, led to a redirection, encountered an error, or met some other outcome.
HTTP status codes are grouped into five classes, each signifying a general category of response:
1xx (Informational): These codes indicate that the request was received, and the server is continuing the process.
- 100 Continue: The server has received the request headers and is waiting for the client to send the request body.
2xx (Successful): These codes signify that the request was successfully received, understood, and accepted.
- 200 OK: The standard response for successful HTTP requests.
- 201 Created: The request was successful, and a new resource was created.
- 204 No Content: The server successfully processed the request and is not returning any content.
3xx (Redirection): These codes mean that further action must be taken to complete the request, often indicating that the client must take additional steps.
- 301 Moved Permanently: The URL requested has been changed permanently, and any further requests should use the new URL.
- 302 Found: The requested resource resides temporarily under a different URL.
- 304 Not Modified: The resource has not been modified since the last request, so the cached version can be used.
4xx (Client Error): These codes are used when the client seems to have made an error.
- 400 Bad Request: The server could not understand the request due to invalid syntax.
- 401 Unauthorized: The request requires user authentication.
- 404 Not Found: The requested resource could not be found on the server.
- 403 Forbidden: The server understood the request, but is refusing to fulfill it.
5xx (Server Error): These codes indicate that the server failed to fulfill a valid request.
- 500 Internal Server Error: An unexpected condition prevented the server from fulfilling the request.
- 502 Bad Gateway: One server on the internet received an invalid response from another server.
- 503 Service Unavailable: The server is currently unable to handle the request, usually due to maintenance or overloading.
These status codes play a vital role in web development, SEO, and the overall user experience. Understanding these codes helps in diagnosing issues, optimizing website performance, and ensuring proper communication between clients and servers.