🌐Authentication failed (401)
401 Unauthorized
The request was turned away because it couldn't be confirmed who you are. You're not logged in, or the API key or token is missing or wrong.
🤔 Why does it happen?
- You're not logged in, or your login has expired
- The API was called without sending the key (API key) or token
- The key was copied wrong, or it's a key from a different project
🔧 Try this
- Log out and log back in
- For an outside API, check that the key is in the environment variable exactly right (including spaces at the start or end)
- Create a new key and swap it in
🤖 Ask your AI like this
I get 401 Unauthorized when I call [which API or feature]. Please check the code to see whether the login info (login session or API key) is being sent correctly, and fix it. Don't write the key directly in the code; read it from an environment variable.
Replace the [ ] parts with your own situation, and paste the error with a few extra lines before and after it.
Related terms
Other errors in this group
- Page not found (404)
404 Not Found - Internal server error (500)
500 Internal Server Error - No permission (403)
403 Forbidden - Too many requests (429)
429 Too Many Requests - CORS error (cross-site request blocked)
blocked by CORS policy - Couldn't send the request (Failed to fetch)
TypeError: Failed to fetch - Connection refused (localhost refused to connect)
ERR_CONNECTION_REFUSED - Mixed content (http request on an https page)
Mixed Content - Request method not allowed (405)
405 Method Not Allowed - What you sent is too big (413)
413 Payload Too Large - The middle server got no answer (502)
502 Bad Gateway - Service temporarily unavailable (503)
503 Service Unavailable - Redirects loop forever (too many redirects)
ERR_TOO_MANY_REDIRECTS - Blocked by an ad blocker
net::ERR_BLOCKED_BY_CLIENT - An image or file won't load
Failed to load resource: 404 (Not Found)