HTTP status code classes explained, from 1xx to 5xx
What each HTTP status class means, the codes developers meet most, and how to read a response code to decide whether the client or the server is at fault.
Reading the first digit
Every HTTP response carries a three-digit status code, and the leading digit tells you the whole story at a glance. 1xx signals that the request was received and is still in progress, 2xx confirms success, 3xx asks the client to look elsewhere, 4xx blames the request, and 5xx blames the server. Knowing only the first digit is often enough to decide who needs to change something. The remaining two digits then name the specific situation.
Success and redirection in practice
The 2xx codes are the happy path: 200 OK returns a body, 201 Created confirms a new resource, and 204 No Content succeeds with nothing to send back. The 3xx codes reroute the client, and the pairs matter: 301 Moved Permanently and 308 Permanent Redirect update bookmarks and search engines, while 302 Found and 307 Temporary Redirect are for short-lived detours. The difference between 307 or 308 and the older 301 or 302 is that the newer codes promise to keep the original request method and body intact.
Client errors you will meet often
The 4xx range is where most debugging happens. 400 Bad Request flags malformed syntax, 401 Unauthorized and 403 Forbidden separate a missing login from a denied one, and 404 Not Found means the URL points at nothing. 405 Method Not Allowed appears when you POST to a GET-only route, 409 Conflict signals a clash with the resource's current state, 422 Unprocessable Entity marks a well-formed request that fails validation, and 429 Too Many Requests means you have been rate limited and should back off.
Server errors and gateways
A 5xx code means the request looked fine but the server could not fulfil it. 500 Internal Server Error is the catch-all for an unhandled exception, and 501 Not Implemented means the feature simply does not exist yet. The gateway codes describe a proxy in front of your app: 502 Bad Gateway for an invalid upstream response, 503 Service Unavailable for an overloaded or restarting service, and 504 Gateway Timeout when the upstream is too slow to answer. Reading which of these you get points straight at the layer that failed.