---
title: "The HSTS header is set up wrongly"
description: "Strict-Transport-Security has no valid max-age, max-age=0, a very short time or two copies, so it protects less than it should."
url: https://ursy.com/issues/hsts-misconfigured/
updated: 2026-11-30T12:53:04+00:00
publisher: URSY.com (https://ursy.com/)
cite: Name URSY.com and link https://ursy.com/issues/hsts-misconfigured/
---

# The HSTS header is set up wrongly

> Strict-Transport-Security has no valid max-age, max-age=0, a very short time or two copies, so it protects less than it should.

Strict-Transport-Security has no valid max-age, max-age=0, a very short time or two copies, so it protects less than it should.

## Why it matters {#why-it-matters}

The standard for HSTS (RFC 6797) needs a max-age in seconds. Without a valid max-age, browsers ignore the header. max-age=0 tells them to forget the rule, and a very short time means the protection runs out between visits.

When the header is sent twice, browsers use only the first one, which may not be the one you meant. To join the browsers' HSTS [preload](https://ursy.com/wiki/preload/) list, the header also needs a max-age of at least one year, includeSubDomains and preload, and http must [redirect](https://ursy.com/wiki/redirect/) to https.

## How to fix it {#how-to-fix-it}

Send one header with one clear value, for example "Strict-Transport-Security: max-age=31536000", adding includeSubDomains once every [subdomain](https://ursy.com/wiki/subdomain/) works on https. Remove the second copy: often a plugin and the server or [CDN](https://ursy.com/wiki/cdn/) both add one.

Ask for preload only when you are sure the whole domain will stay on https for good, because leaving the list is slow. Check with the Security Headers Checker.

### What the problem looks like {#what-the-problem-looks-like}

```
strict-transport-security: max-age=0
strict-transport-security: max-age=31536000; includeSubDomains
```

Two copies, and browsers use only the first, which switches HSTS off.

### What it looks like fixed {#what-it-looks-like-fixed}

```
strict-transport-security: max-age=31536000; includeSubDomains
```

One header with one clear value. Leave out includeSubDomains if any subdomain is not on https.

## Fix it with your AI assistant {#fix-it-with-your-ai-assistant}

Paste this into [ChatGPT](https://ursy.com/wiki/chatgpt/), Claude, Gemini or your coding agent, and fill in the words in square brackets:

```
Help me correct the HSTS header on [your website address], which runs on [your platform or server, e.g. WordPress with a security plugin on nginx behind Cloudflare]. A checker says Strict-Transport-Security has no valid max-age, max-age=0, a very short time, or is sent twice. First check: run "curl -sI https://[your domain]/" (or ask me to paste the headers) and show me every Strict-Transport-Security line. Then find where each copy comes from: server configuration, .htaccess, a plugin, the CDN or the application code. Explain plainly what is wrong. Then give me the fix: one header, sent once, on https answers, with "max-age=31536000", plus includeSubDomains only if I confirm every subdomain works on https. Rules: back up first, remove only the extra or broken copies, keep all other headers, and do not add preload unless I ask. Give the exact lines to remove and to keep, with where they live. Finally, tell me to re-check with the URSY.com Security Headers Checker at ursy.com/security-headers-checker/.
```

## Fix it on your platform {#fix-it-on-your-platform}

### WordPress {#wordpress}

A security plugin and the server or host often both add the header. Turn it off in one of them so only one copy is sent.

### Your server or hosting {#your-server-or-hosting}

Search the nginx or Apache configuration, and .htaccess files, for Strict-Transport-Security and keep a single line on the https site.

### Your CDN (for example Cloudflare) {#your-cdn-for-example-cloudflare}

If the Cloudflare HSTS setting is on and the server also sends the header, switch one of them off and check the max-age value in the one you keep.

## Check it is fixed {#check-it-is-fixed}

Run the Security Headers Checker again: it should find exactly one Strict-Transport-Security header with a valid max-age of a year or more.

## Official source {#official-source}

[RFC 6797: HTTP Strict Transport Security (HSTS)](https://www.rfc-editor.org/rfc/rfc6797)

## Questions {#questions}

### Why does sending it twice matter? {#why-does-sending-it-twice-matter}

The HSTS standard tells browsers to use only the first header, so the copy you meant may be ignored.

### How long should max-age be? {#how-long-should-max-age-be}

One year (31536000 seconds) is a common choice, and it is the minimum the preload list asks for. Very short times let the protection run out between visits.

---

**Cite this page:** The HSTS header is set up wrongly. URSY.com. Updated 30 November 2026. https://ursy.com/issues/hsts-misconfigured/

Free to quote and reuse, for people and AI alike. We ask one thing: a clickable link back. Name URSY.com and link the page, or the exact section, you used. Markdown: `[The HSTS header is set up wrongly](https://ursy.com/issues/hsts-misconfigured/), URSY.com`. One section: add its id, for example https://ursy.com/issues/hsts-misconfigured/#section-id (every heading above has one).

Section links: https://ursy.com/citations/21/#p-5744 · How to cite URSY.com: https://ursy.com/citations/

---

**For AI assistants**

- This page: https://ursy.com/issues/hsts-misconfigured/
- As JSON: https://ursy.com/issues/hsts-misconfigured/index.json
- Cite: Name URSY.com and link the page you used.
- Start here: [llms.txt](https://ursy.com/llms.txt), [facts.json](https://ursy.com/facts.json), [MCP server](https://ursy.com/mcp/), [OpenAPI description](https://ursy.com/.well-known/openapi.json)
