HSTS (HTTP Strict Transport Security)
Want this checked on your own domain?
Join the waitlistUpdated
Message for whoever manages your website
Hi, our site works fully over HTTPS. Could you add the response header “Strict-Transport-Security: max-age=31536000” to our HTTPS responses, on both the www and non-www addresses? Please leave out “includeSubDomains” and “preload” until we’ve confirmed that every subdomain works over HTTPS. Thank you.
Want this checked on your own domain? Join the waitlist.
Check yours
The full domain report (join the waitlist for access) reads the header on your HTTPS homepage. To look yourself:
curl -sI https://example.com/ | grep -i strict-transport-security
No output means the header isn’t sent. The SSL checker confirms the certificate is valid, which HSTS depends on.
Fix it
Before you start. HSTS makes HTTPS mandatory for every browser that has seen the header. If HTTPS later breaks, for example through an expired certificate, those browsers refuse to load the site and give visitors no way to continue (RFC 6797 §8.4, §12.1) until HTTPS works again or the max-age runs out.
- Make HTTPS work everywhere on the name first. Every page loads at https:// without warnings, and http:// redirects to https://. The HTTPS guide covers both.
- Add the header to HTTPS responses:
Strict-Transport-Security: max-age=31536000max-ageis in seconds; 31536000 is 365 days. Send it from every name visitors use, example.com and www.example.com, including the redirect from one to the other. A policy applies only to the name that sent it (plus its subdomains withincludeSubDomains), so a header sent only by www doesn’t protect visitors who type the bare domain (RFC 6797 §11.4.2). - If you want to go slowly, raise
max-agein stages, as hstspreload.org recommends: 300 (5 minutes), then 604800 (1 week), then 2592000 (1 month), checking for broken pages at each stage and waiting the full max-age before the next, and finally 31536000. The report shows “HSTS lasts only briefly” untilmax-agereaches 180 days (15552000). - Add
includeSubDomainsonly when every subdomain works over HTTPS, including internal ones that aren’t public. Browsers that saw it refuse plain HTTP for all of them (RFC 6797 §14.5). It is what lets HSTS protect cookies shared across your subdomains (§14.4). - Leave out
preloadunless you’ve read the preload list section and decided to apply.
Where the header is set.
- Cloudflare: on the SSL/TLS Edge Certificates page, under HTTP Strict Transport Security (HSTS), select Enable HSTS, then set Max Age and leave the subdomain and preload options off unless you mean them. Cloudflare sends the header only on HTTPS requests.
- nginx: in the HTTPS server block. The
alwaysparameter adds the header to redirects and error responses too. Alocationblock with its ownadd_headerlines doesn’t inherit this one, so repeat it there.add_header Strict-Transport-Security "max-age=31536000" always; - Apache (mod_headers): in the HTTPS VirtualHost.
alwaysis needed for the header to appear on redirects.Header always set Strict-Transport-Security "max-age=31536000"
Send the header only on HTTPS responses, and only once. Browsers ignore it over plain HTTP (RFC 6797 §8.1), sites must not send it there (§7.2), and a <meta> tag version is ignored (§8.5).
Confirm. Run the curl command from Check yours against both names and against the redirect between them, then run the report again.
Undoing it. Send max-age=0, which tells each browser to forget the policy the next time it receives the header (RFC 6797 §6.1.1). Keep HTTPS working while you do: browsers that don’t revisit keep the old policy until it expires.
Browsers aren’t told to insist on HTTPS
What it means. Your HTTPS homepage doesn’t send a Strict-Transport-Security header.
Why it matters. Whenever a browser requests an http:// address of your site, for example from an old link or bookmark, that first request goes out unencrypted, even if your server redirects it to HTTPS. Someone on the network path can read that request’s address, rewrite the redirect to keep the browser on HTTP, or add cookies to the response (hstspreload.org, “Benefits of HSTS”). Browsers that try HTTPS first fall back to HTTP when the HTTPS attempt fails, which an attacker can arrange; HSTS removes that fallback for your site.
Fix. Follow the steps above: confirm HTTPS works everywhere, then add Strict-Transport-Security: max-age=31536000 at your host or CDN.
Confirm. The curl check prints the header for both names.
HSTS lasts only briefly
What it means. Your site sends HSTS, but its max-age is under 180 days (15,552,000 seconds). (A header whose max-age is missing or isn’t a number, or that repeats a directive, is ignored by browsers completely, because max-age is required and each directive may appear only once (RFC 6797 §6.1, §6.1.1). The report treats that as no HSTS at all.)
Why it matters. The policy lasts max-age seconds from the last time a browser received the header (RFC 6797 §8.1). A visitor who comes back after it has run out is unprotected again on their first request. 180 days is the same line Mozilla’s HTTP Observatory draws, and the preload list requires a year.
Fix. Raise max-age to 31536000 (one year). If you are partway through a staged rollout, continue it; this result clears once max-age reaches 180 days.
Confirm. The curl check shows the new value.
The site could drop off the HSTS preload list
What it means. Your domain joined the HSTS preload list through hstspreload.org, but the HSTS header on its https:// base domain no longer meets the list’s requirements: a max-age of at least 31536000 (one year; 10886400 for domains preloaded between Chrome 50 and Chrome 63), includeSubDomains, and preload. If the base domain redirects, for example to www, the redirect itself must carry the header.
Why it matters. Browsers still use HTTPS for your domain today. But hstspreload.org says “sites may be removed automatically in the future for failing to keep up the requirements”, and removing preload makes a domain eligible for its removal form. Off the list, browsers rely again on your site’s own redirect and header, so a visitor’s first insecure link can be intercepted.
Fix. Send Strict-Transport-Security: max-age=31536000; includeSubDomains; preload on the https:// base domain’s responses, including any redirect.
Confirm. The curl check against the base domain prints the header with all three settings.
The HSTS preload list
Because a browser learns your policy only from a response, the very first visit is unprotected. The HSTS preload list fixes that: it is built into Chrome, and Firefox, Safari, and Edge use lists based on Chrome’s (hstspreload.org). Browsers never make a plain-HTTP request to a domain on the list.
Requirements (hstspreload.org), which must stay true for as long as the domain is listed:
- A valid certificate.
- A redirect from HTTP to HTTPS on the same host, if the server listens on port 80.
- Every subdomain served over HTTPS, including www if it has a DNS record, and including internal subdomains that aren’t publicly accessible.
- On the base domain’s HTTPS responses, an HSTS header with
max-ageof at least 31536000,includeSubDomains, andpreload. If the HTTPS base domain redirects (for example, to www), the redirect itself must carry the header.
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
Applying and leaving. You submit the domain at hstspreload.org. New entries can take several months to reach the stable version of Chrome. Removal is possible through a separate form, but hstspreload.org warns that it “cannot easily be undone”: it takes months to reach Chrome users, and other browsers make no guarantees. Removing preload from the header makes a domain eligible for removal, and domains that stop meeting the requirements may be removed automatically.
Should you? The list’s maintainers say: “While HSTS is recommended, HSTS preloading is not recommended.” Chrome and Safari already upgrade HTTP navigations to HTTPS on their own, so preloading adds protection only when those upgrades fail under an active attacker. Preload only if you are sure every subdomain, now and in the future, will support HTTPS.
Preloaded top-level domains. Some whole top-level domains are on Chrome’s list, including .app, .dev, .page, .bank, and .insurance. Every site under them must use HTTPS in Chrome and other browsers that use its list, whatever the site’s own header says.
Technical reference
Header syntax (RFC 6797 §6)
Strict-Transport-Security: max-age=31536000; includeSubDomains
- Directives are separated by
;. Order doesn’t matter, names are case-insensitive, and each directive may appear only once. A header that doesn’t match the grammar is ignored entirely; unknown directives are ignored (§6.1). max-ageis required: seconds as digits, optionally quoted (max-age="31536000").max-age=0removes the policy, includingincludeSubDomains(§6.1.1).includeSubDomainsis optional and takes no value (§6.1.2).preloadisn’t defined in RFC 6797. It is the opt-in signal hstspreload.org looks for.
How browsers apply it (RFC 6797 §7 and §8)
- Only a header received over HTTPS with no certificate or connection errors counts. Over plain HTTP it is ignored (§8.1), and a site must not send it there (§7.2).
- If a response carries more than one header, only the first is used (§8.1); a site must send only one (§7.1).
- The policy is stored per host name. With
includeSubDomains, it also covers every subdomain of that name (§8.2). IP-address URLs never match (§8.3). - For a covered host, the browser rewrites http:// to https:// before any request, including when following redirects, and changes an explicit port 80 to 443 (§8.3).
- Any certificate or connection error ends the connection, and the visitor isn’t offered a way to continue (§8.4, §12.1).
- Responses without the header don’t clear the policy; it lasts until
max-ageruns out (§8.6).
What the report checks
- It reads the header on the homepage visitors end up on, and only when that page is served over https:// with status 200, isn’t a bot-protection page, and isn’t on another domain. If the homepage isn’t on HTTPS, this check doesn’t run; the HTTPS check reports that.
- No header, or a header browsers ignore (no valid
max-age, or a repeated directive): “Browsers aren’t told to insist on HTTPS”, saying why when the header is there. max-age(quoted or not) under 15,552,000 seconds: “HSTS lasts only briefly”. Mozilla’s HTTP Observatory uses the same 15,552,000-second line for its six-month test.- Otherwise: “Browsers are told to always use HTTPS (HSTS)”, with the number of days and whether
includeSubDomainsandpreloadare present. - If the homepage’s name is on Chrome’s HSTS preload list, browsers use HTTPS whatever the header says, so none of the results above apply; the report names the list entry that covers it:
- For a name covered by a suffix above the domain (every .app domain, for example), listed at its registry’s request, or listed with no header requirement (Chrome’s own sites, entries added by hand, and those from before Chrome 50): “Browsers always use HTTPS, even on a first visit”.
- For a domain that joined through hstspreload.org: the same, while the header on its https:// base domain, read before any redirect, meets the list’s requirements; otherwise “The site could drop off the HSTS preload list”.
- Not checked: the header on the other name, or on redirect responses other than a preloaded base domain’s.
Sources
- RFC 6797, HTTP Strict Transport Security (HSTS)
- HSTS Preload List Submission (hstspreload.org)
- Chromium HSTS preload list (transport_security_state_static.json)
- Chromium Blog, Towards HTTPS by default (2023-08-16)
- Mozilla HTTP Observatory, Strict-Transport-Security test
- Cloudflare, HTTP Strict Transport Security (HSTS)
- nginx, ngx_http_headers_module (add_header)
- Apache HTTP Server 2.4, mod_headers (Header)
Want this checked on your own domain?
Join the waitlist