Diagnosing HTTP 403 Forbidden Across APIs, WAFs, and Linux Web Servers
HTTP 403 Forbidden signals an authorization or policy denial rather than a missing login. In REST and GraphQL APIs, returning 403 tells the caller that their identity was verified (or irrelevant due to an IP/WAF rule) and re-sending the exact same credentials will not change the outcome. Always inspect which layer emitted the 403—response headers like Server: cloudflare, x-amzn-errortype, or nginx immediately pinpoint whether a CDN WAF, AWS IAM/S3 bucket policy, or your application middleware rejected the request.
On self-hosted Linux servers, 403 Forbidden is frequently a filesystem permission mismatch: Nginx worker processes (www-data or nginx) need execute (x) traversal bits on every parent directory (755 or 711) and read permission (644) on static assets. If a multi-tenant API wants to prevent attackers from enumerating valid resource IDs, RFC 9110 explicitly permits returning 404 Not Found in place of 403.
Re-Authentication EffectRe-authenticating with the same account will NOT grant access
Cacheable / RetryableNot cacheable · Do not auto-retry
When should an API return 404 instead of 403 for unauthorized records?
If revealing that a resource ID exists is a security leak (such as multi-tenant invoices or private Git repositories), return 404 Not Found so unauthorized callers cannot enumerate valid IDs.
Why does Nginx return 403 Forbidden on a brand-new site directory?
Usually because either index.html is missing while autoindex is off, or a parent directory like /home/user lacks the execute bit (chmod 755/711) needed by the www-data user.
Can an unauthenticated request legitimately receive 403 Forbidden?
Yes. If access is forbidden regardless of credentials—such as a blocked IP range, failed WAF signature, or disabled feature—403 is completely valid even without authentication.