20 September 2026 · One command a day
How do I check a website's status code and headers from the command line?
The curl -I command asks a web server for the response headers of a page and prints them, without downloading the page itself. You get the HTTP status code, the server name, any redirect, caching rules and security headers in about a second. You reach for it when a site looks wrong and you want to know what the server is actually saying, with no browser cache or extension getting in the way.
The command
curl -I https://example.com
curl is the tool that fetches URLs from the command line and is installed on Ubuntu 24.04 by default. The -I flag (a capital i) sends a HEAD request, which asks for headers only and no body. The URL is whatever you want to check. Include the scheme, https:// or http://, or curl will assume plain HTTP. It runs as a normal user and needs no sudo.
What you will see
HTTP/2 200
server: nginx
date: Sun, 20 Sep 2026 09:14:02 GMT
content-type: text/html; charset=utf-8
content-length: 12480
last-modified: Fri, 18 Sep 2026 16:40:11 GMT
etag: "68cc3f2b-30c0"
strict-transport-security: max-age=31536000
cache-control: max-age=600
The first line is the one that matters. It shows the protocol and the status code. 200 means the page was served. 301 or 302 means a redirect, and a location: header will tell you where it points. 404 means not found. 502 or 503 usually means nginx is up but the app behind it is not answering. The remaining lines are the headers. server tells you what answered, content-type tells you what kind of file came back, and cache-control tells you how long browsers and CDNs will hold on to it.
When to use it
- A site is showing an error and you want the real status code, not a friendly error page or a stale copy from your browser. A 502 here is your cue to check whether the app is still running under PM2.
- You have just set up a redirect from www to the bare domain, or from http to https, and want to confirm it returns 301 and points to the right place.
- You have changed a header in your nginx config, such as a cache rule or a security header, and want to see it is actually being sent after a reload.
Watch out for
-I sends a HEAD request, not a GET, and not every server treats the two the same. Some apps return 405 Method Not Allowed for HEAD, or send different headers than they would for a real page load. If the result looks odd, run curl -sS -o /dev/null -D - https://example.com instead. That sends a normal GET, throws the body away and prints only the headers. Also, curl does not follow redirects unless you add -L, so on a redirecting site you will only see the first hop.
Questions people ask
How do I check a site on my server before DNS points to it?
Add --resolve example.com:443:127.0.0.1 to the command. curl connects to the address you give while still sending the right hostname, so nginx picks the correct server block and certificate.
How do I see every redirect in the chain?
Add -L to follow redirects. curl prints the headers for each hop in order, so you can watch the request go from http to https to the final page.
On a server you control you can run this from the box itself, against 127.0.0.1, and see exactly what nginx returns before the rest of the internet does. You can get the same VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.
Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.
Affiliate link.