The five classes of HTTP status codes
Every HTTP response carries a three-digit status code whose first digit defines its class. The 1xx codes are informational and signal that the request was received and processing continues. The 2xx codes indicate success, with 200 OK and 201 Created the most common. The 3xx codes signal redirection, telling the client the resource lives elsewhere, as with 301 Moved Permanently and 304 Not Modified.
The 4xx codes mark client errors, where the request was malformed or not allowed, including 400 Bad Request, 401 Unauthorized, 403 Forbidden, and 404 Not Found. The 5xx codes mark server errors, such as 500 Internal Server Error and 503 Service Unavailable.
Choosing the correct code
Picking the right code matters because clients, caches, and search engines act on it. A 301 tells browsers and crawlers to update their links permanently, while a 302 or 307 signals a temporary move. Returning 404 for a missing page lets search engines drop it, whereas returning 200 with an error message can leave broken pages indexed.
The distinction between client and server errors also guides debugging: a 4xx points to something the caller must fix, while a 5xx points to a fault on the server side.