Lab-tested: Local lab server (Python 3.13.5, nginx-style log format) · 2 Dec 2026 · Reproduced and fixed in our lab
Fix Box — Try this first (10 seconds)
Read the code, then read the headers. 401 comes with a WWW-Authenticate header asking for credentials. 403 has no such header — the server understood you and refused.
404 means the address itself does not exist. Our 403 pillar guide covers the 403 side in depth.
The one-line difference
401 means “who are you?” — the request lacks valid authentication. 403 means “I know who you are, and no” — the server refuses to authorize it.
404 means “there is nothing here” — the resource does not exist at that address.
The names mislead people. 401 is called Unauthorized but really means unauthenticated. 403 Forbidden is the true authorization refusal.
Our lab test: all three on one server
We measured all three codes on one local lab server on 2 Dec 2026. Same machine, same client, four different paths:
GET / -> HTTP 200 (baseline, page exists and is public)
GET /private -> HTTP 401 WWW-Authenticate: Basic realm="lab"
GET /forbidden-zone -> HTTP 403 (no WWW-Authenticate header)
GET /missing-page -> HTTP 404 (no WWW-Authenticate header)
The header is the tell. Only the 401 response carried WWW-Authenticate, naming the scheme the server expects. The 403 response carried a log line instead: access forbidden by rule.
The 404 response had neither — just absence.
Comparison table
| Signal | 401 Unauthorized | 403 Forbidden | 404 Not Found |
|---|---|---|---|
| Meaning | Credentials missing or invalid | Request understood, refused | Resource does not exist |
| WWW-Authenticate header | Yes — names the scheme | No | No |
| Retry with credentials? | Yes — that is the fix | No — credentials will not help | No — fix the URL |
| Typical cause | No token, expired token | Deny rule, permissions, WAF | Wrong or deleted URL |
| Fix owner | Client (send valid auth) | Server admin (change the rule) | Site owner (restore or redirect) |
Which fix belongs to which code
If you see 401, fix the credentials: send the token, refresh it, or check its format.
Our sister site covers this in depth at 401.my.id, the diagnostic center for authentication errors.
If you see 403, fix the server side: read the error log, find the deny rule, permission, or WAF block.
Start with the 403 pillar guide and confirm with the 403 Checker.
If you see 404, fix the address: restore the page, correct the link, or add a redirect. No server rule change will conjure a missing page.
One caution: some servers deliberately answer 404 for resources that exist but are forbidden. That hides their existence from scanners.
If a page you know exists returns 404, check whether a security rule is masking a 403.
What Did Not Work
Sending credentials to a 403 endpoint changed nothing in our test. The server had already decided to refuse. Authentication was never the question.
Likewise, relaxing a deny rule did nothing for the 404 path. The file simply was not there.
Each code has exactly one correct fix family, and the other two do not substitute.
FAQ
Frequently Asked Questions
Why is 401 called Unauthorized if it means unauthenticated?
Historical naming from the original HTTP spec. In practice, 401 always means “authenticate first”. The `WWW-Authenticate` header proves it.
Can a 403 turn into a 401?
Only if the server configuration changes. A resource that requires login should answer 401. A resource that refuses everyone should answer 403.
Should missing pages return 403 to hide them?
Some security setups do the reverse and answer 404 for forbidden resources. It reduces information for scanners but confuses legitimate debugging.
Which code should an API return for a bad token?
401 for a missing or expired token. 403 when the token is valid but lacks the required scope. The [API 403 guide](/403-forbidden-api/) covers the split.
Sources and date
Lab test: 2 Dec 2026, local lab server on our SI machine (Python 3.13.5 emitting nginx-style log lines; client IP is localhost).
The four responses above are verbatim measured output.
Measured responses:
GET /private -> 401 + WWW-Authenticate: Basic realm="lab"
GET /forbidden-zone -> 403 + log: access forbidden by rule
GET /missing-page -> 404
References
- RFC 9110 §15.5.3 — 403 Forbidden: https://www.rfc-editor.org/rfc/rfc9110.html
- MDN Web Docs — 401 Unauthorized: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/401
- MDN Web Docs — 403 Forbidden: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/403
- MDN Web Docs — 404 Not Found: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/404




Leave a Reply