Key takeaways
- 401 is about identity (no valid credentials); 403 is about permission (known but not allowed).
- A correct 401 must include a WWW-Authenticate header, or clients cannot tell how to authenticate.
- Googlebot cannot log in, so a public page returning 401 will eventually drop out of the index.
- Leftover staging basic auth after a redesign is the classic cause of accidental sitewide 401s.
- Always test in a private window; cached credentials make a 401 invisible to the person who set it up.
- For API calls, check the Authorization header, the scheme, token expiry, environment mismatch, clock skew and trailing newlines.
- To gate paid content without blocking indexing, use paywall structured data rather than a 401.
Short answer: a 401 Unauthorized status code means the server understood your request but will not serve it because valid authentication credentials are missing or wrong. In plain terms: you have not proved who you are. It is different from 403 Forbidden, which means we know who you are and you still cannot have this.
401 vs 403 vs 404
These three get mixed up constantly, including by developers who should know better.
| Code | Name | Means | Will logging in help? |
|---|---|---|---|
| 401 | Unauthorized | No valid credentials supplied | Yes |
| 403 | Forbidden | Authenticated, but not permitted | No |
| 404 | Not Found | Resource does not exist here | No |
| 407 | Proxy Authentication Required | The proxy needs credentials, not the server | Yes, at the proxy |
The naming is genuinely misleading and has been since the HTTP spec was written. 401 should really be called "Unauthenticated". Remember it this way: 401 is about identity, 403 is about permission.
What a correct 401 response looks like
A 401 is required by the specification to include a WWW-Authenticate header telling the client how to authenticate. Like this:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="Staging Site"
That header is what makes a browser show the username and password popup. If you return a 401 without it, browsers and API clients cannot tell what to do next, which is a surprisingly common bug.
Why you are seeing one
As a visitor
- Wrong username or password. The ordinary case. Check caps lock and keyboard layout.
- Expired session. You were logged in, the token aged out, the next request came back 401. Log in again.
- Stale cookies or cache. Clear cookies for that site, or test in a private window to confirm.
- A browser extension interfering. Privacy and ad-blocking extensions sometimes strip authentication headers. Try with extensions disabled.
- The page is genuinely protected. Admin areas, staging sites and member content return 401 to everyone who is not signed in.
As a developer, calling an API
- Missing Authorization header. Check it is actually being sent; a lot of HTTP clients drop headers on redirect.
- Wrong scheme.
Authorization: Bearer <token>is not interchangeable withBasic. The word matters and it is case sensitive. - Expired or revoked token. Refresh it. If your refresh logic only triggers on a 403, that is your bug.
- Token for the wrong environment. A staging key against a production endpoint returns 401, and the error message rarely says so.
- Clock skew. Signed requests and JWTs fail if the server clock and client clock disagree by more than the allowed window. Worth checking on a container or VM that has been running a while.
- A trailing newline in the key. Copied from a terminal or an env file, invisible, and it breaks everything. This one costs people entire afternoons.
As a site owner
- A leftover
.htpasswdprotection from when the site was in development. The most common cause of an accidental sitewide 401. - A security plugin locking an admin path after failed login attempts.
- Server-level basic auth applied to a directory and forgotten.
- A CDN or WAF rule requiring a header your origin does not send.
The SEO consequence, which is the part that matters
This is why a 401 is worth understanding even if you are not a developer.
Googlebot cannot log in. It has no credentials, so any page returning 401 is a page Google cannot crawl, cannot index, and will eventually drop from the index entirely.
That is correct behaviour for an admin panel. It is a disaster when it happens by accident.
The classic failure
A site is built on a staging URL with basic auth protecting it. The site launches. The protection is removed from the new domain but left on a subdirectory, or the live site goes up with the staging config still in place. Nobody notices because the developers' browsers have the credentials cached. Weeks later, traffic has vanished and Search Console is full of "Blocked due to unauthorized request (401)".
We have seen this twice in audits, both times after a redesign, both times with weeks of lost indexing. Check it yourself in a private window, or with our meta tag checker, which fetches the live URL the way a crawler would rather than the way your logged-in browser does.
What to do if you find it
- Remove the authentication from any page that should be public.
- In Search Console, open Pages and find the 401 group. Confirm it only contains pages that should be private.
- Use URL Inspection and Test live URL on an affected page. It must return 200 before you do anything else.
- Click Validate Fix on the 401 report so Google re-checks.
- Resubmit your sitemap to speed the recrawl along.
Recovery is usually fast once the block is removed, though it is not instant. A page that has been 401 for two months takes longer to come back than one that was blocked for two days.
When you should return a 401 deliberately
Use it correctly and it protects things properly.
- Admin and dashboard paths. Yes, 401 is right.
- Staging and development environments. 401 keeps them out of Google entirely, which is better than a
noindextag that might get crawled and ignored. - API endpoints without a valid token. 401 with a clear
WWW-Authenticateheader. - Paid or member content? Be careful here. If you want the content indexed so people can find it, 401 blocks that. Use a paywall structure with
isAccessibleForFreestructured data instead, so Google can index it while you still gate it.
That last distinction is where businesses lose organic traffic without realising. Blocking a crawler and gating a human are two different jobs, and a 401 does both at once.
Quick diagnosis
| Symptom | Likely cause | Fix |
|---|---|---|
| Browser popup asking for user and password | Basic auth on the server | Remove the .htpasswd rule, or enter credentials |
| API worked yesterday, 401 today | Expired token | Refresh the token; check refresh triggers on 401 |
| 401 only on one environment | Wrong key for that environment | Check which key the config is loading |
| Search Console shows 401 on public pages | Leftover staging protection | Remove it, then Validate Fix |
| Works for you, 401 for everyone else | Cached credentials in your browser | Always test in a private window |
That last row is the one to internalise. "It works on my machine" is the most expensive sentence in web development, and a cached 401 credential is one of the quietest ways it happens. If anything on this list points at your own site, the fix is usually a one-line server change, and it is the kind of thing a web development check catches before it costs you two months of indexing.
Frequently asked questions
It means the server understood your request but will not serve it because valid authentication credentials are missing or wrong. You have not proved who you are, so logging in with correct credentials usually resolves it.
A 401 is about identity: no valid credentials were supplied, so authenticating will help. A 403 is about permission: the server knows who you are and you are still not allowed, so logging in changes nothing.
Re-enter your credentials carefully, log in again if your session expired, clear cookies for that site or test in a private window, and try with browser extensions disabled since some strip authentication headers.
Most often an expired or revoked token. Also check that the Authorization header is actually being sent, that the scheme matches (Bearer versus Basic), that you are not using a staging key against production, and that there is no invisible trailing newline in the key.
Badly, if it is on a page that should be public. Googlebot cannot log in, so a 401 page cannot be crawled or indexed and will be dropped from the index over time. Search Console reports this as "Blocked due to unauthorized request (401)".
Almost always leftover basic auth from the staging environment. It stays invisible to the developers because their browsers have cached the credentials, so always check the live site in a private browsing window.
Only if you do not want it indexed. A 401 blocks Google entirely. To keep paid content discoverable while still gated, use a paywall structure with isAccessibleForFree structured data instead.
Remove the authentication, confirm the page returns 200 using Test live URL in Search Console's URL Inspection tool, then click Validate Fix on the 401 report and resubmit your sitemap.
Want results like this for your business?
We plan, execute and report on SEO, ads and web for businesses across Noida and Delhi NCR, with numbers you can actually check.