Who is asking for credentials
- 401 Unauthorized
- The server hosting the resource
- 403 Forbidden
- Nobody; the server refuses
- 407 Proxy Authentication Required
- A proxy between client and server
A 401 means the request lacks valid credentials for the resource. Learn the WWW-Authenticate challenge, how it differs from 403, and how to fix it.
HTTP 401 Unauthorized means the request has not been applied because it lacks valid authentication credentials for the target resource. The server must send a WWW-Authenticate header naming how to authenticate. Fix it by sending valid credentials in an Authorization header. If you already did, the server refused them. If you are signed in and still blocked, you are probably looking at a 403.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
HTTP/1.1 401 Unauthorized
Date: Tue, 02 Jul 2024 12:18:47 GMT
WWW-Authenticate: BearerCommon schemes in MDN's list include Basic (RFC 7617), Bearer (RFC 6750, bearer tokens for OAuth 2.0-protected resources) and Digest (RFC 7616). Basic sends credentials base64-encoded, not encrypted, so use it only over HTTPS.
The client asks for a protected URL with no Authorization header.
It answers 401 with a WWW-Authenticate header, for example WWW-Authenticate: Bearer or WWW-Authenticate: Basic realm="Access to the staging site".
The client repeats the request with an Authorization header, whose format depends on the scheme: Authorization: <type> <credentials>. Browsers usually show a password prompt first.
Valid credentials get the resource. Invalid ones get another 401. Valid credentials without enough rights get a 403.
# Basic
curl -i -u user:password https://example.com/admin
# Bearer token
curl -i -H "Authorization: Bearer $TOKEN" https://example.com/api/meIn nginx, the auth_basic module answers with a 401 and a WWW-Authenticate: Basic challenge when credentials are missing or wrong (see ngx_http_auth_basic_module.c in nginx's source). The module's own docs give this example:
location / {
auth_basic "closed site";
auth_basic_user_file conf/htpasswd;
}The parameter of auth_basic is used as the realm. For a 403 where you expected a 401 in nginx, see 403 in nginx.
Google lists 401 among the 4xx codes it handles alike (except 429): the content is treated as not existing, and an indexed URL is removed from the index. It also says 401 and 403 have no effect on crawl rate. Google doesn't index URLs that return a 4xx status code, so a login-gated page that returns 401 stays out of search, and a public page that returns 401 to Googlebot will drop out. See 4xx errors and Google's page on how HTTP status codes affect its crawlers.
4 questions people ask next, answered from the sources on this page.
A 401 says the request lacks valid authentication credentials and must carry a WWW-Authenticate challenge, so new credentials can work. A 403 says the server understood the request and refuses it; MDN says authenticating or re-authenticating makes no difference.
A framework in which the server challenges a request with 401 and a WWW-Authenticate header, and the client answers with an Authorization header. MDN notes the exchange is the same for most schemes, though the header contents differ.
The server is not accepting the credentials sent. Check that the Authorization header is present, that its scheme matches the challenge, that the token hasn't expired, and that no proxy is stripping the header.
The page needs you to sign in or the credentials you gave were rejected. If you are signed in and still blocked, expect a 403 instead, which signing in again won't fix.
Run the free audit, then approve the fixes. Every change can be undone.