Client error · 401
401 Unauthorized
A 401 Unauthorized means the server will not fulfill the request until the client authenticates. The name is historical. The code means “not authenticated,” even when people say unauthorized.
HTTP status codes explained · the longer reference on the blog.
What 401 means
On the spec, a 401 response includes a WWW-Authenticate header that tells the client which scheme to use, such as Basic or Bearer. Browsers react to that header with a sign-in prompt. Many APIs omit the header and return JSON instead. The status still means the same thing: the server did not accept credentials for this call.
A public homepage should not return 401. A login route, an admin path, or an API without a token should. If your marketing site suddenly answers 401, a deploy likely put the whole origin behind auth, or a proxy is challenging every request.
Common causes
No credential was sent
The cookie expired, the Authorization header was dropped by a proxy, or a monitor called a private URL with no token. The server is doing what it was configured to do.
The credential is expired or signed wrong
A JWT past exp, a clock skew between the app and the identity provider, or a token signed with the previous key after a rotation. The request arrives, and auth rejects it.
The whole site was put behind a login
HTTP basic auth on the server block, a “maintenance lock,” or an auth middleware mounted at / instead of /admin. Every URL, including the homepage, then returns 401.
A CDN cached the 401
A challenge response was stored and is now served to later visitors. Cache rules should not store responses that depend on Authorization or cookies.
How to fix it
Decide whether this URL is supposed to be public
If it is private, 401 is a success condition for an anonymous caller. Monitor a public health URL, or set the monitor’s expected status only if you intentionally want anonymous 401 to count as up.
Inspect WWW-Authenticate and the auth logs
The header names the scheme. The identity provider or app log names the failure: expired, unknown client, bad signature, or user not found.
Check middleware order after the last deploy
A global auth guard is the usual reason a previously public page starts returning 401. Narrow the matcher to the routes that need it.
Bypass the cache once
Request the origin directly, or send a cache-busting query, and compare the status. If only the CDN returns 401, purge that URL and stop caching authenticated responses.
Is it your site, or just you?
Try a private window. If the page loads there, your session cookie is the problem. If the private window also gets 401, the URL is challenging every anonymous visitor.
The homepage checker sends no login cookie. A 401 from the checker means an anonymous visitor is being challenged. A 200 from the checker, while you still see 401, points at your session or a header your browser adds.
How to monitor for 401
Point a monitor at a URL that should be public, such as the homepage or /health. A 401 there fails a monitor that expects 200. Leave login and token URLs off the anonymous check, or you will alert on a lock that is working as designed.
The checker on the ismysiteup homepage requests the URL from our servers and shows the HTTP status, response time, and SSL details. No account is required, and that checker allows 5 checks per hour from the same network. A free account watches 5 URLs, each checked every 10 minutes, and sends alerts on WhatsApp, Telegram, Slack, or email. A monitor expects HTTP 200 unless you set a different expected status (100–599). One failed check is confirmed with a second check before the first alert, and a later success sends a recovery alert. Pro (every 5 minutes) and Business (every minute) are listed on the pricing page; paid checkout is not open yet.
Related status codes
FAQ
How is 401 different from 403?
A 401 asks the client to authenticate. A 403 means the server refuses the request and a different login is not being offered. APIs mix the two up. Read the body, and look for WWW-Authenticate on a 401.
Should my uptime monitor follow a 401?
Only as a failure, when the URL is meant to be public. A 401 on a private API from a checker that has no token is the lock working. Watch a route you expect to answer 200.
Can a CDN cause a sitewide 401?
Yes. A cached 401, or an access policy on the CDN, is served before your app runs. Compare the CDN response with a request that goes straight to the origin.