What is an HTTP status code; what do the 2xx, 3xx, 4xx and 5xx classes describe?
Short answer
An HTTP status code is the three-digit number on the first line of the response that reports how the server concluded the request; the first digit gives the class: 2xx success (200 OK), 3xx redirect (301, 302), 4xx client error (403, 404), 5xx server error (502, 503, 504). In TR7, the status code is used for both decisions and monitoring: the Status Code condition works on the response code of the Backend Service and is used only at the response stage; the Expected Status Codes field of the Health Checks profile determines the codes to be considered healthy; actions such as Block and Show Content let the code to be returned to the client be selected in the Status Code field; the HTTP Logs screen filters records with the Status Class and Status Code filters; the 4xx responses/sec and 5xx responses/sec thresholds in the Notifications profile send a notification when the error rate rises.
Where It Is Used in TR7
| Where | Field / label | What for |
|---|---|---|
| Load Balancer → Conditions (Policy Match) → Criteria | Status Code (comparison with Operator) | Running an action based on the response code of the Backend Service; only at the response stage |
| Load Balancer → Profiles (L4-L7 Behavior Sets) → Health Checks → HTTP / HTTPS profile | Expected Status Codes (default 200) | The response codes to be considered healthy |
| Load Balancer → Actions (Policy Actions) → Block | Status Code (default 403) | The code to be returned to the blocked request |
| Load Balancer → Actions (Policy Actions) → Show Content | Status Code (default 200) | The code to be returned with the content page |
| Load Balancer → Actions (Policy Actions) → Show Content for Traffic Manager Errors, Show Content for Backend Service Errors, Redirect for Traffic Manager Errors, Redirect for Backend Service Errors | Error Codes | Showing a content page or redirecting on the selected error codes |
| vService → Logs & Tracking → HTTP Logs → Filter | Status Class (2xx Success, 3xx Redirect, 4xx Client error, 5xx Server error), Status Code | Filtering records by class or by code |
| Load Balancer → Profiles (L4-L7 Behavior Sets) → Notifications | 4xx responses/sec, 5xx responses/sec (off by default) | A notification when the threshold for the number of error responses per second is exceeded |
Classes
| Class | Meaning | Example |
|---|---|---|
| 1xx | Informational | 100 Continue, 101 Switching Protocols: switching to WebSocket |
| 2xx | Successful | 200 OK, 204 No Content |
| 3xx | Redirect | 301, 302, 304 Not Modified |
| 4xx | Client error | 400, 403, 404, 418 |
| 5xx | Server error | 500, 502, 503, 504 |
The classes are defined in RFC 9110 · Status Codes.
Common Misconceptions
- "5xx is always an error produced by the application." 502, 503 and 504 can also be returned by TR7 without the request receiving a response from the Backend Service; the Response Source filter in HTTP logs shows the source of the response. Possible causes: Users see "503 Service Unavailable" / "No Available Server"; what should I do?, I get 502 Bad Gateway; what are the possible causes?, I get 504 Gateway Timeout; which timeout should I check?.
- "418 is a server error." 418 is in the 4xx class; TR7 WAF returns this code by default when blocking (Why is the 418 status code returned by default on a block; can I change it?).
- "The Status Code condition evaluates the request." The status code is created in the response; the condition is used only in actions that run at the response stage.
How it is done in the documentation
