An HTTP status code class is the group a code belongs to, set by its first digit: 1xx informational, 2xx success, 3xx redirection, 4xx client error and 5xx server error. Clients are expected to treat an unrecognized code like the x00 code of its class.
Why it matters
The class is the quickest triage signal. A 4xx says the request was the problem, so retrying unchanged will fail again. A 5xx says the server failed, so retrying may succeed. A 3xx asks the client to go elsewhere. Monitoring uses classes too: alerting on the share of 5xx responses is more robust than listing every individual code.
Example
2xx 200 OK, 204 No Content
3xx 301 Moved Permanently, 304 Not Modified
4xx 404 Not Found, 429 Too Many Requests
5xx 500 Internal Server Error, 503 Service Unavailable
A custom API that returns an unregistered code such as 299 is still, by the rules, a success to well-behaved clients. A monitor might define "healthy" as any 2xx and flag a 3xx on a URL that should answer directly.
Common mistakes
- Returning 200 for errors with the failure only in the body, which hides outages from monitors and caches.
- Treating every 4xx as the user's fault when a bad deploy can break valid requests.
- Retrying 4xx responses automatically.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.