Check a Website's HTTP Status Code with curl

Print just the HTTP status code and response time of any URL with curl, ideal for health checks and quick monitoring from the terminal.

LinuxcurlDiagnosticsLow risk
Run curl -s -o /dev/null -w "%{http_code}\n" https://example.com to print the site's HTTP status code.

01Command

Command
$ curl -s -o /dev/null -w "%{http_code} %{time_total}s\n" https://example.com

02What it does

The -o /dev/null part throws the page body away so only the summary is printed, while -w writes selected variables after the transfer finishes — %{http_code} is the status (200, 301, 404, 500...) and %{time_total} the whole-request time in seconds. This works well in shell scripts and cron jobs as a poor man's uptime check: anything other than 2xx means something changed. Add -L if you want curl to follow redirects before reporting the final code.

03Risk

RiskLow risk
!Warning: Some servers return different codes to curl than to real browsers (bot detection or compression differences), so a 403 here does not always mean the site is down for users.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • curl(1) — Linux manual page
    Arch Linux · community · 2026-09-17
    Evidence: Documents -o, -s and -w/--write-out variables such as http_code and time_total for summarizing a transfer.
  • curl man page — -w / --write-out and %{http_code}
    curl · vendor-doc · 2026-09-17
    Evidence: Documents the --write-out variables including http_code and time_total, used to print the response status and timing after a request.

Last verified: 2026-09-18 · Category: Network

06Related solutions