HTTP 403 vs 401 Fix

401 and 403 are both access failures, but they point to different checks. Debug the auth header, user permissions and proxy rules separately.

Symptoms

  • API returns 401 without a valid or accepted credential.
  • API returns 403 even though the user is logged in.
  • A CDN or WAF returns 403 before the request reaches the app.

Likely causes

  • Missing, expired or malformed Authorization header.
  • Authenticated user lacks permission for the resource.
  • Server, CDN, WAF or file permissions deny access.

Fix steps

  1. Inspect WWW-Authenticate, Location and security-related headers.
  2. Reproduce with cURL using a placeholder token.
  3. Check application logs and proxy/CDN logs for where the response is created.

Verify the fix

  • Test without auth, with bad auth and with a known-good token.
  • Confirm expected status codes are documented.
  • Check headers after any proxy or CDN change.

FAQ

When should an API return 401?

When authentication is missing or invalid.

When should an API return 403?

When authentication may be known but access to the resource is forbidden.

Related tools and guides

Last updated: May 18, 2026