HTTP Status Codes / 4xx HTTP Status Codes / HTTP 401

401 Unauthorized (RFC 7235)

This is an educational reference page about HTTP 401 Unauthorized. The page itself is served as 200 OK so it can be indexed as HTTP documentation.

Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the requested resource. See Basic access authentication and Digest access authentication. 401 semantically means "unauthorised", the user does not have valid authentication credentials for the target resource. Note: Some sites incorrectly issue HTTP 401 when an IP address is banned from the website (usually the website domain) and that specific address is refused permission to access a website.

What it means

HTTP 401 Unauthorized means authentication is required, missing, invalid, or expired. The client may try the request again with valid credentials.

Common causes

How to fix it

Example response

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="api"
Content-Type: application/json

{"error":"Missing access token"}

Developer notes

401 is about authentication. 403 is about authorization.

Questions

What does HTTP 401 mean?

HTTP 401 means the request needs valid authentication before the server can return the protected resource.

Is 401 the same as 403?

No. Use 401 when credentials are missing or invalid. Use 403 when the client is authenticated but not allowed.

Related comparisons

4xx client error – the request contains bad syntax or cannot be fulfilled


HTTP status code lookup
By Ping Now, a website/API/service uptime monitor
Data from Wikipedia