401 HTTP Origin: Network OSI layer 7 · Application Last updated 18 Nov 2026

401 Unauthorized without WWW-Authenticate header

The server answered 401 but didn't say which authentication scheme to use.

Exact message you may see 401 without WWW-Authenticatemissing WWW-Authenticate header 401WWW-Authenticate header required 401 response
Seen on: HTTP REST API

Meaning

RFC 7235 requires WWW-Authenticate on every 401. Without it browsers can't show a Basic prompt and clients can't discover Bearer/realm details. Add the header (Bearer realm="api") or use 403 where authentication isn't possible.

Common causes

  • API framework returning 401 without the header
  • Custom middleware ignoring the spec
  • Proxy stripping the header
  • Misuse of 401 for authorisation failures
  • Client can't discover the auth scheme

⚡ Quick fix

  1. Send WWW-Authenticate: Bearer realm="api"
  2. Use 403 for authenticated but forbidden
  3. Don't strip the header at the proxy

Detailed fix by platform

Node.js

  1. res.status(401).set("WWW-Authenticate", 'Bearer realm="api"').json({ error: "unauthorized" });

How to diagnose

  1. Header — Present?
  2. Scheme — Documented?
  3. Proxy — Strips it?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

100 — HTTP 100 Continue (HTTP)100103 — HTTP 103 Early Hints (HTTP)1031040 — Cloudflare Error 1040 / 1041: Invalid request header modification (Cloudflare)1040400 — 400 Bad Request: Request Header Or Cookie Too Large (HTTP)400400 — 400 Bad Request: invalid character in header (HTTP)400401 — HTTP 401 Unauthorized (HTTP)401401 — 401 Bearer error="invalid_token" (HTTP)401401 — 401 because the Authorization header is stripped (HTTP)401401

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.