TapCub is live — analytics, insights and live chat, free on one platform
Glossary

401 Error: HTTP 401 Unauthorized Meaning and Fixes

A 401 error means the request lacked valid authentication credentials. How it differs from 403, 404 and 407 under RFC 9110, a decision flow for the cause, and fixes for visitors, site owners, API callers and crawlers.

Xu An Reviewed by Lucas Hayes Also called HTTP 401 Last updated Nov 28, 2026 Glossary

Quick answer

A 401 error (HTTP 401 Unauthorized) means the server refused the request because it lacks valid authentication credentials: none were sent, or the password, cookie, key or token was rejected. RFC 9110 requires a WWW-Authenticate header. A 403 means you are known but not allowed.

What is a 401 error?

A 401 error (HTTP 401 Unauthorized) is the status code a server returns when a request "lacks valid authentication credentials for the target resource", in the words of RFC 9110, the current HTTP standard. Either no credentials were sent, or the ones sent (a password, a session cookie, an API key or token) were rejected. Despite the name, 401 is about authentication (who you are), not authorization (what you are allowed to do).

RFC 9110 adds one hard rule that distinguishes a real 401 from a mislabelled one: a server generating a 401 response MUST send a WWW-Authenticate header with at least one challenge, telling the client which authentication scheme to use. A minimal valid response looks like this:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="example"

If the request did include credentials, the 401 means those credentials were refused. The client may retry with new or replaced credentials; if it gets the same challenge again after trying, RFC 9110 says the browser should show the response body to the user, because it usually explains what went wrong.

Common ways the error appears on screen: "401 Unauthorized", "HTTP Error 401", "401 Authorization Required", "Access denied", or a browser sign-in dialog that keeps coming back.

401 vs 403 vs 404 vs 407

The four codes are often swapped. RFC 9110 separates them by what the server knows and what the client can do next:

CodeRFC 9110 meaningRequired headerWill new credentials help?Typical cause
401 UnauthorizedRequest lacks valid authentication credentialsWWW-Authenticate (MUST)Yes, that is the pointNot logged in, expired session or token, wrong password or key
403 ForbiddenServer understood the request but refuses itNoneNot with the same credentials; maybe neverLogged in but lacks permission, IP or country block, firewall rule
404 Not FoundNo current representation, or the server will not disclose oneNoneNoWrong URL, deleted page, or a private page being hidden
407 Proxy Authentication RequiredLike 401, but a proxy between client and server needs credentialsProxy-Authenticate (MUST)Yes, proxy credentialsCorporate proxy, scraping proxy without login

Two details matter in practice. First, RFC 9110 lets a server that wants to hide a forbidden resource answer 404 instead of 403, so a 404 on a private page can be deliberate. Second, OAuth 2.0 bearer-token APIs (RFC 6750) split the token cases precisely: an expired, revoked or malformed token should get 401 with error="invalid_token", while a valid token without enough scope should get 403 with error="insufficient_scope". Other status codes are covered in HTTP 500 errors (server faults) and 406 Not Acceptable (content negotiation).

Why a 401 happens: a decision flow

Work through these questions in order; the first "yes" is usually the cause.

  1. Was any credential sent? Open the browser's developer tools (Network tab) or log the request. No Authorization header and no session cookie means the client never authenticated: not logged in, cookie blocked, or the header stripped by a proxy or redirect.
  2. Was the credential valid but expired? Sessions time out; access tokens often expire after a fixed lifetime. If requests worked earlier and started failing at a regular interval, it is expiry. The response's WWW-Authenticate value may say error="invalid_token".
  3. Was the right scheme used? The challenge names the scheme (Basic, Bearer, Digest and others). Sending a Bearer token to an endpoint that challenges with Basic fails every time.
  4. Was it sent to the right place? A key for the staging environment, the wrong project, or a different host returns 401 even though the key itself is fine. So does a mistyped URL that lands in a protected path.
  5. Is the response really a 401? If there is no WWW-Authenticate header, the server is misusing the code, and the real problem may be a permission issue (should be 403) or an application bug.

How to fix a 401 error, by who sees it

If you are a visitor:

  • Check the URL for typos and use the site's normal entry page rather than an old bookmark.
  • Log out and log in again; if a password manager filled the form, type the password manually.
  • Clear the site's cookies and cache, then retry. Disable extensions that block cookies for that one site.
  • If the sign-in dialog keeps returning, the account may not have access; contact the site owner.

If you own the site:

  • Make sure protected pages are meant to be protected. A staging password left on a production folder is a common cause.
  • Confirm every 401 response carries a WWW-Authenticate header, and return 403, not 401, when the user is logged in but not allowed.
  • Check session length and cookie settings (domain, SameSite, Secure) if users are logged out unexpectedly.
  • Remove internal links from public pages to login-only areas so visitors and crawlers do not hit them.

If you call an API:

  • Read the response body and the WWW-Authenticate header; many APIs return a machine-readable error code more specific than the status.
  • Refresh an expired token and retry once. Repeating the same failing request in a loop can trigger rate limits.
  • Check the environment, project and key name; never paste a full key into a ticket or chat.

If the client is a crawler:

  • Search engine crawlers do not log in. Google's documentation on HTTP status codes says all 4xx codes except 429 are treated the same: the URL is not indexed, and a previously indexed URL is removed. Google also says not to use 401 or 403 to slow crawling.
  • If a page should rank, it must return 200 to an anonymous request. If it should stay private, 401 is correct, and the page should not appear in your sitemap.

Worked example: 401s in a crawl log

Sample data. A site imports a week of server logs and filters to one search engine crawler:

StatusFetchesShare
200 OK1,70085.0%
301 Moved Permanently603.0%
401 Unauthorized24012.0%
Total2,000—

Counting a fetch as successful when the status is below 400, the success rate is (1,700 + 60) ÷ 2,000 = 88.0%. All 240 failures come from /account/ and /orders/ URLs linked from the site header. Those pages should stay private, so the fix is not to remove the login. It is to stop advertising them to anonymous clients: drop them from the sitemap and point the header link to the login page. If the 240 fetches move to public pages that return 200, the success rate becomes 2,000 ÷ 2,000 = 100%, and the crawler spends that budget on pages that can rank. You can check URLs one by one with the method in how to check URL status codes.

Seeing 401 responses in TapCub

TapCub does not test whether your pages are up or check them on a schedule; it reports the status codes in the records it receives. For the crawl-log example:

Crawl health cards: total crawls, success rate, unique pages crawled, 404s and 5xx
Demo data: crawl health cards. A status code below 400 counts as success; records without a status code also count as success, so import server-side records to see 401s lower the rate.
  1. Get status codes in. The page script cannot see HTTP status codes, and the log upload on the Data import page skips crawlers. Send crawler requests from your server instead: access records (with a status field) to POST /api/v1/server/events, or Nginx / Apache log lines to POST /api/v1/server/logs/import, using a key from Configuration › Settings › API keys. Only then do 4xx and 5xx responses split out.
  2. Read crawl health. Monitoring › Crawl health shows total fetches, success rate (a status code below 400 counts as success), distinct pages, 404s and 5xx, split by search engine. A 401 lowers the success rate; open the engine's row to see which pages it fetched most. Step-by-step: check crawl health.
  3. Check each crawler. Web analytics › Bots lists every crawler with its most common status code, so a crawler that mostly gets 401 stands out.
  4. Know what the error report is not. Monitoring › Errors records JavaScript exceptions on your pages, not HTTP status codes. A login page that returns 401 will not appear there unless a script also throws.

TapCub's own API follows the same pattern: it takes Authorization: Bearer keys, and a missing or wrong key returns 401.

Sources

Was this explanation clear?

We use your answers to fix and expand this page.

Xu An

Customer Experience Consultant

Writes about live chat, visitor conversations, and self-service, sharing practical ways to make customer communication clearer and more effective.

FAQ

Questions people ask

Short answers to the follow-up questions that come up most.

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

What does error code 401 mean?

It means the server could not authenticate the request: no credentials were sent, or the ones sent were invalid or expired. RFC 9110 calls it 401 Unauthorized and requires a WWW-Authenticate header that tells the client which authentication scheme to use. Logging in again or refreshing the token usually fixes it.

What is the difference between a 401 and a 403 error?

A 401 is about identity: the server does not know who you are, and valid credentials would help. A 403 is about permission: the server understood the request, may know who you are, and still refuses. Sending the same credentials again will not change a 403.

How do I fix a 401 error?

As a visitor, check the URL, log in again and clear the site's cookies. As a site owner, make sure only private pages are protected and every 401 carries a WWW-Authenticate header. As an API caller, refresh the expired token and retry once. For crawlers, return 200 on pages meant to rank.

Does a 401 error hurt SEO?

Only for pages you want indexed. Google treats a 401 like other 4xx codes: it does not index the URL and drops it if it was indexed. Private pages should return 401, but keep them out of your sitemap and public navigation so crawlers do not waste fetches on them.

See this number on your own site

Add one script tag for web and apps, and the first reports fill in within minutes.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics