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
- 1Check that you are including the correct authentication credentials in your request.
- 2Verify your API key or token has not expired.
- 3Ensure the Authorization header uses the correct scheme (Bearer, Basic, etc.).
- 4If using sessions, check if you need to log in again.
- 5Review the WWW-Authenticate response header for the expected authentication method.
Tags
httpclient-errorauthenticationunauthorizedsecurity
Related Items
More in 4xx Client Error
http-400-bad-requestHTTP 400 Bad Request — What It Means & How to Fix It
Errorhttp-402-payment-requiredHTTP 402 Payment Required — What It Means & How to Fix It
Errorhttp-403-forbiddenHTTP 403 Forbidden — What It Means & How to Fix It
Errorhttp-404-not-foundHTTP 404 Not Found — What It Means & How to Fix It
Errorhttp-405-method-not-allowedHTTP 405 Method Not Allowed — What It Means & How to Fix It
Errorhttp-406-not-acceptableHTTP 406 Not Acceptable — What It Means & How to Fix It
ErrorFrequently 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.