How does HSTS keep a browser on HTTPS?
Useful first: HTTP · optional, not a requirement
Choose your depth
Stay with the essentials, or look closer.
YOUR GOALDistinguish a browser's HTTPS-only rule from encryption and a server redirect.
Remember to use HTTPS
A rule about the connection
HTTPS protects HTTP traffic using a secure connection. HSTS adds a browser rule: require HTTPS for this host. It does not supply encryption or install a certificate. The server must already support secure access.
[4] [5]Upgrade before the request
Suppose your browser already knows the HSTS policy for shop.example. Opening http://shop.example/cart becomes an HTTPS request before an insecure request is sent. An ordinary server redirect instead needs a request to reach the server first.
The first visit is different
A fresh browser may not yet know that policy. Learning it from a later HTTPS response cannot protect an earlier HTTP request. A built-in preload entry can supply advance knowledge. Browsers may also upgrade requests through separate HTTPS-first features; those are not proof that HSTS was learned.
[3] [4]A remembered HTTPS-only rule can avoid the insecure request that precedes a redirect.
HSTS is another name for HTTPS encryption.
HTTPS secures the exchange; HSTS tells the browser to require secure access.
Show the explanation
It upgrades the URL before sending an insecure HTTP request. The known policy changes the request before it reaches the server. Transport protection does not certify the site's content.
YOUR GOALInterpret max-age and subdomain coverage without treating the header as a one-time switch.
Read the policy and its lifetime
Accept the rule securely
A teaching example is Strict-Transport-Security: max-age=86400; includeSubDomains. Delivered over valid HTTPS, it asks the browser to remember the rule for 86,400 seconds: one day. A header received over insecure HTTP is ignored. This example explains syntax, not a production rollout plan.
A moving expiry time
Receiving the same policy again restarts its lifetime from that receipt. Omitting the header later does not erase a stored policy. A securely received max-age=0 removes that host's stored policy; it does not turn off HTTPS itself.
Subdomains inherit coverage
With includeSubDomains, a policy for example.com also covers login.example.com. The child cannot cancel the parent's coverage with its own zero lifetime. Check HTTPS readiness across subdomains before enabling this scope; a child's separately learned policy can also outlive the parent's policy.
Lifetime and domain coverage determine which stored rules still apply.
Removing the header immediately clears every browser's HSTS state.
A browser can retain its previously received policy until expiry.
Show the explanation
The existing policy can remain until its stored expiry. An absent header does not revoke stored state. Expiry still matters; receiving a new policy can change it.
YOUR GOALReason about first-contact protection and failure cases without assuming HSTS repairs a server.
Preloading, ports and hard failures
A header token is not a deployed preload entry
Preloading distributes HTTPS-only knowledge with browser software. Merely adding preload does not prove inclusion in a reader's browser list. Submission, inclusion and browser updates are separate steps. As checked on 22 November 2026, the preload service recommends HSTS but does not recommend preloading; removal can take time.
Ports do not all become 443
For a known HSTS host, http://api.example:80/status becomes https://api.example:443/status. But http://api.example:8080/status keeps port 8080 after the scheme changes. That port must support HTTPS. Without an explicit port, the rewritten HTTPS URL uses its default, 443.
A certificate problem remains a problem
If establishing TLS to a known HSTS host produces a certificate error, the browser fails the connection instead of offering the ordinary click-through exception. HSTS cannot renew a certificate or restore an unavailable server. The secure connection still has to succeed before HTTP requests can be exchanged.
[1] [5]Strict transport enforcement can expose broken HTTPS; it cannot repair it.
HSTS makes any certificate acceptable because HTTPS is mandatory.
Requiring secure access also means refusing a connection that fails its security checks.
Show the explanation
Keep port 8080 and use HTTPS there. The special port rewrite is 80 to 443. Other explicit ports remain, so HTTPS must work on the selected port.
Keep asking. Check the details.
Source-checked using AI (OpenAI Codex) on . The checks covered sources, examples, and quizzes for this article version.
No human review is claimed. AI review can miss errors; check the original sources below.
- MDN — Strict-Transport-Security header
- IETF — RFC 6797: HTTP Strict Transport Security
- Chromium HSTS preload service — behavior and deployment limits
- Chromium — HTTP Strict Transport Security
- IETF — RFC 9110: HTTPS URI scheme