Skip to content
Latchkey

HTTPie --check-status: Fail CI on 4xx and 5xx

http --check-status exits 4 on a 4xx response and 5 on a 5xx, so a bad status fails the pipeline step.

By default HTTPie exits 0 even on a 500, because the request itself succeeded. In CI you almost always want the opposite; --check-status maps HTTP status classes onto exit codes.

What it does

--check-status sets the process exit code from the response: 0 for 2xx (and 3xx when not following), 3 for an unfollowed 3xx, 4 for any 4xx, and 5 for any 5xx. This turns a health check into a build gate without piping through grep or jq.

Common usage

Terminal
http --check-status --ignore-stdin GET example.com/health
# quiet smoke test: no body, just the exit code
http --check-status --ignore-stdin --quiet GET :8080/ready
# combine with follow so redirects resolve before the check
http --check-status --follow GET example.com/

Options

Exit codeMeaning
0Success (2xx, or 3xx when following redirects)
3Response was a 3xx and redirects were not followed
4Response was a 4xx
5Response was a 5xx
2Request timed out

In CI

Always pair --check-status with --ignore-stdin in a pipeline so HTTPie does not hang reading a redirected or closed stdin. Add --quiet (-q) when you only care about the exit code and do not want the body in the log.

Common errors in CI

A step that keeps passing on a broken endpoint means --check-status was omitted, so HTTPie returned 0. Exit code 3 in CI means the endpoint returned a redirect you did not follow; add --follow. Exit code 2 means a timeout, not a bad status; raise --timeout or fix the endpoint.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →