Back to all status codes
401

Unauthorized

Authentication is required. The request lacks valid authentication credentials.

Common Causes

  • Missing authentication token
  • Expired token
  • Invalid credentials
  • Missing Authorization header

Fix Solutions

Include authentication

Add valid authentication token or credentials to the request.

Refresh expired tokens

Implement token refresh logic to handle expired tokens.

Code Examples

# Basic authentication
location /admin {
    auth_basic "Admin Area";
    auth_basic_user_file /etc/nginx/.htpasswd;
}

Related Tools