What is hsts
Last updated: April 1, 2026
Key Facts
- HSTS is implemented through an HTTP response header that tells browsers to enforce secure HTTPS connections for specified durations
- Browsers remember HSTS requirements and automatically upgrade HTTP requests to HTTPS for affected domains, preventing user override
- The HSTS header specifies a max-age duration during which the browser enforces the policy, typically ranging from months to years
- HSTS preload lists maintained by browsers allow websites to be included for automatic HTTPS enforcement even on first visit
- HSTS requires a valid SSL/TLS certificate and full HTTPS implementation; websites cannot use HSTS with self-signed certificates
Overview
HTTP Strict Transport Security (HSTS) is a web security mechanism that forces browsers to establish secure, encrypted connections with websites using HTTPS. Implemented through an HTTP response header, HSTS eliminates the opportunity for attackers to intercept communications by downgrading connections to unencrypted HTTP. This security measure protects against man-in-the-middle attacks, session hijacking, and other attacks that exploit unencrypted connections.
How HSTS Works
When a website sends the HSTS header in its HTTP response, the browser caches this instruction for the specified duration. During this period, the browser automatically converts any HTTP requests to that domain into HTTPS requests before sending them to the server. This occurs at the browser level, before any data travels across the network, preventing attackers from intercepting or downgrading the connection. Different domains and subdomains can have separate HSTS policies.
HSTS Header Structure
The HSTS header follows the format: Strict-Transport-Security: max-age=[seconds]; includeSubDomains; preload. The max-age parameter specifies how long the browser enforces the policy in seconds. The includeSubDomains directive extends the policy to all subdomains. The preload directive indicates the site's inclusion in browser preload lists, enabling HSTS enforcement even on initial visits before receiving the header.
Benefits and Implementation
HSTS provides critical protection against protocol downgrade attacks where attackers force users from HTTPS to HTTP. It eliminates user behavior risks, such as typing http:// instead of https:// in the address bar. For sensitive websites handling authentication, financial transactions, or personal data, HSTS is essential security infrastructure. Implementation requires a valid SSL/TLS certificate and careful configuration to avoid locking users out of sites with certificate issues.
HSTS Preload and Best Practices
Websites can submit their domain to HSTS preload lists maintained by Chromium, Firefox, and other browsers. Inclusion ensures HSTS enforcement from the first visit, providing maximum security. Best practices include starting with conservative max-age values before increasing duration, testing thoroughly before implementation, and maintaining valid SSL/TLS certificates. Removal from preload lists requires formal requests and can take considerable time.
Related Questions
What is the difference between HSTS and HTTPS?
HTTPS encrypts data during transmission, while HSTS enforces the use of HTTPS. HTTPS is the underlying protocol; HSTS is a mechanism ensuring browsers always use it, preventing downgrade attacks.
Can I remove a website from the HSTS preload list?
Yes, websites can request removal from HSTS preload lists through official removal portals. However, removal takes time as the updated list must propagate to all browsers, potentially taking months.
What happens if my SSL certificate expires with HSTS enabled?
Users will receive certificate error warnings and cannot bypass them like they could without HSTS. This makes maintaining valid certificates critical. Prepare certificate renewals well in advance to prevent service disruptions.
More What Is in Daily Life
Also in Daily Life
More "What Is" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
- MDN - HTTP Strict Transport SecurityCC-BY-SA-2.5
- RFC 6797 - HTTP Strict Transport SecurityPublic Domain