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.

CodeNameMeansWill logging in help?
401UnauthorizedNo valid credentials suppliedYes
403ForbiddenAuthenticated, but not permittedNo
404Not FoundResource does not exist hereNo
407Proxy Authentication RequiredThe proxy needs credentials, not the serverYes, 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

  1. Wrong username or password. The ordinary case. Check caps lock and keyboard layout.
  2. Expired session. You were logged in, the token aged out, the next request came back 401. Log in again.
  3. Stale cookies or cache. Clear cookies for that site, or test in a private window to confirm.
  4. A browser extension interfering. Privacy and ad-blocking extensions sometimes strip authentication headers. Try with extensions disabled.
  5. 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

  1. Missing Authorization header. Check it is actually being sent; a lot of HTTP clients drop headers on redirect.
  2. Wrong scheme. Authorization: Bearer <token> is not interchangeable with Basic. The word matters and it is case sensitive.
  3. Expired or revoked token. Refresh it. If your refresh logic only triggers on a 403, that is your bug.
  4. Token for the wrong environment. A staging key against a production endpoint returns 401, and the error message rarely says so.
  5. 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.
  6. 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

  1. A leftover .htpasswd protection from when the site was in development. The most common cause of an accidental sitewide 401.
  2. A security plugin locking an admin path after failed login attempts.
  3. Server-level basic auth applied to a directory and forgotten.
  4. A CDN or WAF rule requiring a header your origin does not send.
401, 403 and 404 responses compared as three different door states

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

  1. Remove the authentication from any page that should be public.
  2. In Search Console, open Pages and find the 401 group. Confirm it only contains pages that should be private.
  3. Use URL Inspection and Test live URL on an affected page. It must return 200 before you do anything else.
  4. Click Validate Fix on the 401 report so Google re-checks.
  5. 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 noindex tag that might get crawled and ignored.
  • API endpoints without a valid token. 401 with a clear WWW-Authenticate header.
  • 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 isAccessibleForFree structured 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

SymptomLikely causeFix
Browser popup asking for user and passwordBasic auth on the serverRemove the .htpasswd rule, or enter credentials
API worked yesterday, 401 todayExpired tokenRefresh the token; check refresh triggers on 401
401 only on one environmentWrong key for that environmentCheck which key the config is loading
Search Console shows 401 on public pagesLeftover staging protectionRemove it, then Validate Fix
Works for you, 401 for everyone elseCached credentials in your browserAlways 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.