HTTP 401 Unauthorized

You need to log in, or the credentials you sent are missing, wrong or expired.

Unauthorized

4xx Client errorStandardRFC 9110, section 15.5.2

You need to log in, or the credentials you sent are missing, wrong or expired.

Example response
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="api", error="invalid_token", error_description="The access token expired"
Content-Type: application/json
Date: Sun, 15 Nov 2026 09:30:00 GMT

{"error":"invalid_token"}

What 401 means

The request needs authentication and it’s missing or didn’t work. Despite the name, it means unauthenticated (“who are you?”), not unauthorised. The response must include a WWW-Authenticate header saying how to authenticate.

When servers send it

When there are no credentials, or the token, password or API key is wrong, expired or revoked.

Common causes

  • An expired access token (JWTs often last only 5 to 60 minutes).
  • No Authorization header, or a typo such as Bearer missing.
  • A proxy or CDN stripping the Authorization header.
  • A clock difference between machines making a fresh token look expired or not yet valid.

How to fix it as a developer

  • Check the token’s exp and nbf claims with the JWT decoder.
  • Send it as Authorization: Bearer <token>, with one space and no quotes.
  • Refresh tokens before they expire, and retry once after refreshing on a 401.
  • As the server, include WWW-Authenticate, and use 403 (not 401) when you know who the user is but they lack permission.

How to fix it as a visitor

  • Log in again. Your session may have expired.
  • If you’re logged in, log out and back in, or clear cookies for the site.

Related codes

  • 403 Forbidden: The server understood who you are and won’t let you do this.
  • 407 Proxy Authentication Required: Like 401, but it’s a proxy between you and the server that wants you to log in.
  • 404 Not Found: There’s nothing at this URL, or the server won’t say whether there is.
  • 419 Page Expired: Laravel’s code for a form whose security (CSRF) token has expired or is missing.

Where it’s defined

401 Unauthorized is defined in RFC 9110, section 15.5.2. It’s a 4xx code, the client error class: something is wrong with the request, so sending it again unchanged won’t help.

Other 4xx codes

400 Bad Request · 402 Payment Required · 403 Forbidden · 404 Not Found · 405 Method Not Allowed · 406 Not Acceptable · 408 Request Timeout · 409 Conflict · 410 Gone · 413 Content Too Large · 414 URI Too Long · 415 Unsupported Media Type · 418 I’m a teapot · 422 Unprocessable Content · 429 Too Many Requests · 431 Request Header Fields Too Large · 451 Unavailable For Legal Reasons · 499 Client Closed Request

Or search them all in the HTTP status code list.

Questions people ask

What does HTTP 401 Unauthorized mean?
You need to log in, or the credentials you sent are missing, wrong or expired.
What’s the difference between 401 and 403?
401 means “we don’t know who you are”: log in or send valid credentials. 403 means “we know who you are, and you’re not allowed”. Logging in again won’t fix a 403.
Does a 401 need a WWW-Authenticate header?
Yes. RFC 9110 says a server generating a 401 must send WWW-Authenticate with at least one challenge, such as Bearer or Basic.
Why do I get 401 with a token that works elsewhere?
Common reasons: the token is for a different audience or environment, it has just expired, a proxy is dropping the Authorization header, or the server’s clock is off.
↑↓ move↵ openesc close