Check HTTP headers and redirects with curl

· 4 min read

curl shows in one line what a web server really answers: status code, redirect target, security headers. No browser cache, extension or cookie gets in the way. This guide covers the three most common checks, explains the HSTS header with max-age=31536000, and lists the error messages curl gives you along the way.

Show headers, follow redirects, check HSTS

curl comes preinstalled on Linux, macOS and Windows (since Windows 10). Choose what you want to check and enter your domain.

What to check
Tool

Only inserted into the commands in your browser.

All headers · curl · Linux, macOS

-I fetches only the headers (a HEAD request), -s hides the progress meter. The first line gives protocol and status code, followed by one header per line.

Shell
curl -sI https://example.com
Sample output
HTTP/2 200 
date: Tue, 10 Nov 2026 13:44:14 GMT
content-type: text/html; charset=utf-8
last-modified: Thu, 05 Nov 2026 21:17:41 GMT
alt-svc: h3=":443"; ma=86400

All headers · PowerShell · Windows

In PowerShell type curl.exe rather than curl: in Windows PowerShell 5.1 curl is an alias for Invoke-WebRequest and does not understand these options.

PowerShell
curl.exe -sI https://example.com

Redirects · curl · Linux, macOS

-L follows every redirect; the filter keeps only status lines and targets. Each HTTP line is one hop: here one jump from http to https, then the page itself.

Shell
curl -sIL http://example.com | grep -iE "^(HTTP|location)"
Sample output
HTTP/1.1 301 Moved Permanently
Location: https://example.com/
HTTP/2 200 

Redirects · PowerShell · Windows

Select-String plays the part of grep and ignores case by default.

PowerShell
curl.exe -sIL http://example.com | Select-String "^(HTTP|location)"

HSTS · curl · Linux, macOS

Shows only the HSTS header. No output means the site does not send one. Check the https address; over http the header has no effect.

Shell
curl -sI https://example.com | grep -i strict-transport-security
Sample output
strict-transport-security: max-age=31536000; includeSubDomains

HSTS · PowerShell · Windows

The same check on Windows. Empty output means the header is missing.

PowerShell
curl.exe -sI https://example.com | Select-String "strict-transport-security"

With HTTP/2 curl prints header names in lower case, with HTTP/1.1 as the server sent them. That is presentation only; header names are case-insensitive. This is why grep always runs with -i here.

What max-age=31536000; includeSubDomains does

The Strict-Transport-Security header (HSTS) tells the browser to reach the domain over HTTPS only. max-age is how many seconds it remembers that: 31536000 seconds are 365 days, and every visit restarts the clock. During that time the browser rewrites any http address of the domain to https by itself and offers no "proceed anyway" on certificate errors.

includeSubDomains extends this to every subdomain, including ones that do not exist yet or are only used internally. So increasing max-age to 31536000 and adding includeSubDomains is a one-year commitment: a subdomain without a valid certificate becomes unreachable for everyone who visited before, and you cannot take it back until the period has run out in their browsers.

HTTP
Strict-Transport-Security: max-age=31536000; includeSubDomains

One year plus includeSubDomains is also what the browser preload list requires, together with the preload token. The HSTS guide explains how to raise max-age in safe steps.

Security headers only, and counting redirects

Some servers answer HEAD requests differently from normal ones or reject them with 405. The first line therefore sends a regular GET, discards the body and prints only the headers, filtered to the security-relevant ones. The second counts the redirects and names the destination.

Shell
curl -s -o /dev/null -D - https://example.com | grep -iE "^(strict-transport|content-security|x-frame|x-content-type|referrer-policy|permissions-policy)"

curl -sIL -o /dev/null -w "%{num_redirects} redirects, final: %{url_effective} (%{http_code})\n" http://example.com

The second line answers with something like "1 redirects, final: https://example.com/ (200)". More than two hops is a chain that can almost always be cut to one. Both lines are written for Linux and macOS (grep, /dev/null); for Windows use the PowerShell variants in the selector above.

curl error messages

With -s curl stays silent on errors too. Drop the s for diagnosis or write -sS. The usual suspects:

  • curl: (6) Could not resolve host: the name does not resolve in DNS, a typo or a missing A record.
  • curl: (60) SSL certificate problem: certificate has expired: the certificate is past its date. Other variants of the same number name an incomplete chain or an unknown issuer. -k shows the headers anyway but fixes nothing.
  • curl: (47) Maximum (50) redirects followed: a redirect loop. Without -L you see where the first hop points.
  • curl: (28) after a long wait: timeout, the server does not answer on that port. --connect-timeout 5 shortens the wait.
  • HTTP/2 403 or a challenge page: a firewall blocks curl's user agent. That says nothing about the headers browsers get.
  • No HSTS header in the answer: you queried the http address, or the response is itself a redirect. What matters is the last hop over https.

Checking without a terminal

The HTTP header check fetches the page, lists every response header and rates each security header; the redirect checker follows every hop and reports status code, target and response time. What a redirect chain costs and how to untangle it is covered in the guide on 301 redirects.

Frequently asked questions

How do I show only the HTTP headers with curl?
curl -sI https://example.com sends a HEAD request and prints only the headers. If it has to be a GET request, use curl -s -o /dev/null -D - https://example.com.
What does increasing max-age to 31536000 with includeSubDomains do?
Browsers remember for one year that the domain and all of its subdomains are reachable over HTTPS only. Every subdomain then needs a valid certificate, and the commitment cannot be withdrawn early for people who already visited.
How does curl follow redirects?
With -L. Combined with -I curl prints the headers of each hop in turn: curl -sIL http://example.com. Without -L curl stops at the first response.
Why does curl show different headers than my browser?
The browser sends different request headers (user agent, accept, cookies) and uses its cache. Servers and services in front of them may answer differently. curl shows the response to a plain request with no history.
Check now

Free HTTP header check: HSTS, Content-Security-Policy, X-Content-Type-Options, X-Frame-Options, Referrer-Policy and Permissions-Policy, with fixes.

DomainWarn checks security headers, redirects and certificates of all client domains on a schedule and tells you when a header disappears after a deployment.

Monitor this domain continuously14-day free trial, no credit card.

More guides