401 Unauthorized without WWW-Authenticate header
The server answered 401 but didn't say which authentication scheme to use.
401 without WWW-Authenticatemissing WWW-Authenticate header 401WWW-Authenticate header required 401 response 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
- Send
WWW-Authenticate: Bearer realm="api" - Use 403 for authenticated but forbidden
- Don't strip the header at the proxy
Detailed fix by platform
Node.js
res.status(401).set("WWW-Authenticate", 'Bearer realm="api"').json({ error: "unauthorized" });
How to diagnose
- Header — Present?
- Scheme — Documented?
- 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:
Similar errors
Most viewed in HTTP
Other ways to find it
Where this error sits
Origin: Network. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 18 Nov 2026