TR EN

HTTP 401 Unauthorized: authentication checks

A 401 response means valid authentication credentials are missing. Start with the failing request and the server’s authentication challenge.

401

HTTP 401 Unauthorized

HTTP RFC Standard

First decide: visiting a site or maintaining an API?

As a visitor: open the site’s normal sign-in page and sign in again. If the error persists, report the page address, time and any request ID to the site owner; omit private query values. Never send your password or session cookie with the report.

As a developer: reproduce the failing method and URL in your own environment. A successful homepage request says nothing about a protected API route.

Check a 401 in this order

  1. Read the challenge. RFC 9110 requires a WWW-Authenticate response header with a 401. Its scheme helps identify the expected authentication. If absent, inspect the application or gateway generating the response.
  2. Check the actual request. In your browser’s Network panel or local client, verify that the intended cookie or Authorization header is present. Keep credentials out of shared screenshots and public diagnostic tools.
  3. Match the credential to the service. Check expiry, revocation and environment: a staging token may not be accepted by production. Use the service’s documented renewal process.
  4. Trace the rejection. Correlate the request time or ID with authentication logs. Check whether a proxy forwards the expected credentials. Correct the failing configuration, then retry the same route.

Inspect the original response with curl

Replace the example URL with a read-only resource you administer. This unauthenticated GET prints headers and discards the body:

curl -sS -D - -o /dev/null --max-time 15 https://example.com/protected-resource

No -L is used, so a redirect cannot silently replace the initial response. -I would send HEAD instead of GET. This example does not reproduce authenticated or POST requests; use your own client for those. Response headers can contain cookies, so redact them before sharing.

401 versus 403

403 Forbidden means the server understood the request but refuses it. Renewing a token alone may not fix an access-policy rejection. Do not remove authentication to make a private endpoint return 200.

Public pages and Google Search

Google does not index content served with 401. Keep private pages protected; investigate accidental authentication on pages intended for public search. Do not use 401 to slow crawlers. Google’s HTTP guidance.

Reference: RFC 9110, 401 semantics. Related: diagnosing a 500 server error and the HTTP status directory.

Frequently Asked Questions

Will clearing browser data always fix 401?
No. Sign in again first. A revoked token, proxy configuration or server-side authentication problem requires a different fix. Clearing all browser data can remove unrelated sessions.
Does a custom 401 error page fix authentication?
No. Changing the displayed error page does not establish a valid session or credential. Diagnose the authentication layer and preserve the appropriate response status.