HTTP 401 Unauthorized: What It Means and How to Fix It

DIRECT ANSWER

HTTP 401 Unauthorized means the endpoint requires authentication, but the request did not include acceptable credentials or the credentials were rejected. Confirm the exact URL, method, authentication headers and response headers, then check which application, server, proxy or CDN produced the response. HTTP 401 is different from HTTP 403, which generally means the request was understood but access is not permitted.

Key takeaways

  • HTTP 401 is an authentication response, not proof that the entire website is down.
  • DNS and TLS can work normally because the request reached an HTTP-speaking endpoint.
  • Check the exact URL, method, credentials, cookies or authorization headers, and response headers before changing configuration.
  • Use the response timestamp and request identifier, when available, to find the producing layer and matching logs.
  • Make the narrowest safe correction; do not disable authentication or broadly change permissions to hide the symptom.
Reviewed 2026-09-25 HTTP & Server Errors
SA

Site Administrator

Last reviewed: September 25, 2026

What this error means & how to recognize it

  • A browser, API client, monitoring tool or website checker reports 401 Unauthorized.
  • A protected page or API route prompts for sign-in, rejects a session, or returns an authentication error body.
  • The same host may serve some public URLs successfully while one route or request method returns 401.
  • A request can receive HTTP 401 even when DNS resolution and TLS negotiation are working.
  • Response headers may identify authentication requirements, redirects, cache behavior, a proxy or CDN, and sometimes a request or correlation ID.
  • Requests made with a browser session may behave differently from requests made by an API client or monitoring service.

Root causes, ordered by likelihood

  1. Missing or invalid authentication — The request has no credentials, an expired session, an invalid token, an incorrect password, or an improperly formatted authorization header.
  2. Wrong request context — The client is using the wrong URL, HTTP method, host, audience, scope, cookie, API key or environment, so credentials valid elsewhere are not accepted here.
  3. Application authentication rules — Middleware, route guards or session validation reject the request before the application handler runs.
  4. Web-server, reverse-proxy, CDN or WAF rules — An infrastructure layer requires authentication or forwards incomplete, altered or missing credentials.
  5. Caching or routing behavior — A cached response, unexpected redirect, stale route, or host/protocol mismatch sends the client to an endpoint with different authentication requirements.
  6. Upstream configuration or service changes — A deployment, identity-provider change, secret rotation, proxy change or environment mismatch causes previously valid requests to fail.

How to fix it

1Is the final response HTTP 401? If not, investigate thefinal status after redirects and intermediary responses.2Is 401 expected for this route and method? If yes,verify the client’s authentication flow; if no,continue to the producing layer.3Are credentials present and appropriate? Checktoken/session validity, format, scope, audience, host,method and environment without logging secrets.4Did a redirect, cache, proxy or CDN alter the request?Compare the original and final request plus relevantheaders.5Which component generated 401? Match the timestamp,route and request ID against application, server, proxy,CDN or WAF logs.6Was there a recent change? Review deployments, identityconfiguration, secret rotation and routing changes, thenmake one narrow authorized correction and retest.7Did behavior improve without widening access? Verifyboth protected and public routes before closing theincident.
Diagnostic flow at a glance — full detail in the steps below.

For visitors

  1. Verify the exact address and retry once without repeatedly refreshing.
  2. If the resource requires an account, sign in through the site’s normal interface and retry. Check whether the session has expired.
  3. If only one link fails, report that specific URL rather than assuming the whole site is unavailable.
  4. Record the approximate time, page or API endpoint, and the displayed 401 message. Do not send passwords, cookies, access tokens or other secrets.
  5. Contact the site owner if a normally public page returns 401 or sign-in succeeds but the protected resource remains inaccessible.

For API clients and developers

  1. Reproduce the failure with the same HTTP method, URL, host, query parameters, headers and body used by the failing client. Use a non-production account or test credential where possible.
  2. Confirm that the credential is present, unexpired, correctly formatted and intended for this host, route and environment. Check token scope or audience where the authentication system uses them.
  3. Capture the status, response headers and response body without exposing secrets. Pay particular attention to authentication challenge information, redirects, cache headers and request IDs.
  4. Compare a known-good request with the failing request one difference at a time. Check cookies, authorization headers, proxy forwarding, redirects and the request method.
  5. Identify the component that generated the response: application, web server, reverse proxy, CDN or WAF. A response body, distinctive headers and layer-specific logs can help distinguish them.
  6. Inspect the matching logs using the timestamp, route, client and request ID. Check recent deployments, identity-provider changes, secret rotation, routing updates and proxy configuration.
  7. Apply the narrowest authorized correction—for example, fixing a route-specific credential or forwarding rule—and retest the same request. Do not disable authentication, cache private responses publicly, or grant broad permissions as a first response.
  8. Test related public and protected routes, relevant HTTP methods, and the intended unauthenticated behavior to ensure the correction did not create an access-control problem.

Distinguish 401 from nearby failures

  • 401 Unauthorized: authentication is missing, invalid or not accepted by the endpoint.
  • 403 Forbidden: the server understood the request but will not authorize access; valid authentication may still be present.
  • 404 Not Found: the route or resource is not available at that location, although some systems intentionally conceal protected resources this way.
  • 5xx response: the server-side processing failed rather than simply rejecting authentication.

Prevention & how to verify the fix

  • Monitor authentication failures by route, method, client type and deployment so an isolated route problem is distinguishable from a wider incident.
  • Keep authentication, routing, proxy and caching configuration version controlled and review changes before release.
  • Test expected unauthenticated, authenticated and insufficient-permission responses for important web routes and API methods.
  • Use separate credentials and configuration for development, testing and production; rotate secrets through a controlled process.
  • Prevent access tokens, cookies and passwords from appearing in application, proxy, monitoring or support logs.
  • Preserve sanitized request IDs, timestamps and layer-specific logs long enough to investigate authentication failures.
  • Document which routes are intentionally public, protected or restricted by method and client type.

When to get outside help

Escalate to the site, application or identity team when 401 appears unexpectedly on a public route, affects many users or clients, begins after a deployment or credential change, or requires changes to authentication, proxy, CDN, WAF or server configuration. Provide the affected route and method, time zone and timestamp, sanitized response headers, client type, recent change information and request or correlation ID. Never share passwords, session cookies, API keys, access tokens or private authorization headers.

Run a website check

Frequently asked questions

Does HTTP 401 mean the whole website is down?

No. HTTP 401 describes the response to a particular HTTP request. A single route, method, client type or authentication state can fail while public pages and other endpoints continue to work.

Is HTTP 401 the same as HTTP 403 Forbidden?

No. A 401 response indicates that authentication is missing, invalid or not accepted. A 403 response generally means the request was understood but access is not permitted, even when the requester is authenticated.

Can DNS and TLS be healthy when a request returns HTTP 401?

Yes. Receiving an HTTP response normally shows that the request reached an HTTP-speaking endpoint. DNS resolution and TLS negotiation are separate parts of the connection and may succeed even when authentication fails.

Why does a browser work while an API client receives 401?

The browser may send a session cookie or follow an interactive sign-in flow that the API client does not. Compare the host, redirects, cookies, authorization header, token audience or scope, HTTP method and environment without copying secrets into logs.

What should a site owner check first after an unexpected 401?

Confirm the exact request and determine which layer generated the response. Then compare a known-good request, inspect relevant response headers, and match the timestamp or request ID to application, server, proxy, CDN or WAF logs.

Should I keep retrying an HTTP 401 response?

Not indefinitely. Verify the authentication flow and retry only when the client can obtain or refresh valid credentials. Repeated unauthenticated requests can add noise and may interact poorly with rate limits or other protective controls.

Further documentation

For implementation-specific troubleshooting, consult the documentation for the web server, application framework, identity provider, reverse proxy, CDN or WAF that generated the response.