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:
| Code | RFC 9110 meaning | Required header | Will new credentials help? | Typical cause |
|---|---|---|---|---|
| 401 Unauthorized | Request lacks valid authentication credentials | WWW-Authenticate (MUST) | Yes, that is the point | Not logged in, expired session or token, wrong password or key |
| 403 Forbidden | Server understood the request but refuses it | None | Not with the same credentials; maybe never | Logged in but lacks permission, IP or country block, firewall rule |
| 404 Not Found | No current representation, or the server will not disclose one | None | No | Wrong URL, deleted page, or a private page being hidden |
| 407 Proxy Authentication Required | Like 401, but a proxy between client and server needs credentials | Proxy-Authenticate (MUST) | Yes, proxy credentials | Corporate 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.
- Was any credential sent? Open the browser's developer tools (Network tab) or log the request. No
Authorizationheader and no session cookie means the client never authenticated: not logged in, cookie blocked, or the header stripped by a proxy or redirect. - 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-Authenticatevalue may sayerror="invalid_token". - Was the right scheme used? The challenge names the scheme (
Basic,Bearer,Digestand others). Sending a Bearer token to an endpoint that challenges with Basic fails every time. - 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.
- Is the response really a 401? If there is no
WWW-Authenticateheader, 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-Authenticateheader, 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-Authenticateheader; 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:
| Status | Fetches | Share |
|---|---|---|
| 200 OK | 1,700 | 85.0% |
| 301 Moved Permanently | 60 | 3.0% |
| 401 Unauthorized | 240 | 12.0% |
| Total | 2,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:

- 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
statusfield) toPOST /api/v1/server/events, or Nginx / Apache log lines toPOST /api/v1/server/logs/import, using a key from Configuration › Settings › API keys. Only then do 4xx and 5xx responses split out. - 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.
- Check each crawler. Web analytics › Bots lists every crawler with its most common status code, so a crawler that mostly gets 401 stands out.
- 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
- IETF, RFC 9110: HTTP Semantics (§15.5.2 401, §15.5.4 403, §15.5.5 404, §15.5.8 407, §11.6.1 WWW-Authenticate), June 2022, checked 2026-11-28.
- IETF, RFC 6750: OAuth 2.0 Bearer Token Usage (§3.1 error codes), October 2012.
- Google Search Central, How HTTP status codes affect Google's crawlers, checked 2026-11-28.
- MDN Web Docs, 401 Unauthorized.
Was this explanation clear?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.

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