HTTP 401 — Unauthorized
4xx Client Error
What it means
Authentication is required and either missing or invalid. Despite the name, this is about authentication, not permission.
What to do about it
Check the Authorization header is present and correctly formatted, and that the token has not expired. The server should reply with a WWW-Authenticate header saying which scheme it expects.
Where it sits
401 belongs to the 4xx family: The request contains something the server will not or cannot process. The fix is normally on the client side.
HTTP/1.1 401 Unauthorized
Checking it yourself
# see the status code and headers only
curl -sI https://example.com/path
# follow redirects and print each hop
curl -sIL -o /dev/null -w "%{http_code} %{url_effective}\n" https://example.com/path
# JavaScript
const r = await fetch(url);
console.log(r.status, r.statusText);