curl -s -o /dev/null -w '%{http_code}\n' http://localhost

Category: Web Servers & Proxies

curl -s -o /dev/null -w '%{http_code}\n' http://localhost

Print only the HTTP status code from localhost

-s silences progress output, -o /dev/null discards the body, and -w prints the status code with a trailing newline. A 200 means nginx served the default site, while 404 or 502 points to a config or backend problem. Wrap it in a script for simple uptime checks.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.