Error Codes Wiki

HTTP 401 Unauthorized — What It Means & How to Fix It

Error4xx client error

Overview

The HTTP 401 Unauthorized status code indicates the request requires authentication. The client must provide valid credentials to access the resource.

Key Details

  • Despite its name, 401 means unauthenticated, not unauthorized (which is 403).
  • The response should include a WWW-Authenticate header indicating the authentication method.
  • Common authentication schemes include Basic, Bearer (token), and Digest.
  • The client should retry the request with proper authentication credentials.
  • API keys, JWTs, or session cookies may be missing or expired.

Common Causes

  • No authentication credentials were provided in the request.
  • The provided API key, token, or session cookie is invalid or expired.
  • The Authorization header is malformed or uses an unsupported scheme.
  • A login session has timed out and needs to be refreshed.

Steps

  1. 1Check that you are including the correct authentication credentials in your request.
  2. 2Verify your API key or token has not expired.
  3. 3Ensure the Authorization header uses the correct scheme (Bearer, Basic, etc.).
  4. 4If using sessions, check if you need to log in again.
  5. 5Review the WWW-Authenticate response header for the expected authentication method.

Tags

httpclient-errorauthenticationunauthorizedsecurity

Related Items

More in 4xx Client Error

Frequently Asked Questions

It means the request lacks valid authentication credentials. You need to provide a valid API key, token, or login credentials to access the resource.