403 Forbidden
The server understood the request and refuses to carry it out. Authenticating again as the same user will not help.
What 403 means
A 403 is a decision, not a malfunction. The server worked out what you asked for and declined. If you sent credentials, it considers them insufficient; but the refusal may have nothing to do with identity at all: an IP block, a firewall rule or a file permission produces the same code.
A client should not automatically repeat the request with the same credentials. The server may explain itself in the body, and it is free not to. It may also answer 404 instead, to avoid confirming that the resource exists.
Causes on a web server
On a static site or a freshly configured server, 403 nearly always comes from one of three things, and the error log says which.
| Cause | nginx error log | Fix |
|---|---|---|
| The server's user cannot read the file or enter a parent directory | open() ... failed (13: Permission denied) | Files readable (644) and every directory on the path searchable (755) by the nginx user; on SELinux systems, the right context as well |
| The URL is a directory with no index file | directory index of ... is forbidden | Add index.html, correct the index directive, or enable autoindex if a listing is wanted |
| An access rule matched | access forbidden by rule | Review allow and deny in that location |
Apache has the same three: file permissions, a directory without a DirectoryIndex file while Options lacks Indexes, and access control. The last is logged as client denied by server configuration and usually means a missing Require all granted in the <Directory> block, or a Require rule in .htaccess.
Causes in applications and in front of them
- Missing permission or scope. You are logged in, but your role cannot do this, or the API token was created without the scope the endpoint needs.
- CSRF protection. A form posted without a valid CSRF token is rejected with 403 by many frameworks. An expired session in a tab left open overnight is the classic trigger.
- A firewall or bot filter. A WAF or CDN blocks the request by IP address, country, user agent or a pattern in the payload. The page is branded by the provider, not by the site, and often carries a reference ID.
- Hotlink protection and other
Refererchecks. - Object storage. Amazon S3 answers 403, not 404, for an object that does not exist when the caller has no permission to list the bucket.
What you can do as a client
- Read the response body. An API usually names the missing permission.
- Check which account or key you are using, then its roles and scopes. Decoding a JWT in the JWT decoder shows the scopes it actually carries.
- If the block page comes from a firewall, try without a VPN, and send the reference ID to the site owner if it persists.
- In scripts, set a truthful
User-Agent. Default library user agents are blocked by many bot filters. - Do not retry in a loop. Unlike 429 or 503, a 403 does not clear with time.
403 compared with 401, 404 and 405
| Code | The server is saying | Next step |
|---|---|---|
| 403 Forbidden | I know what you want and the answer is no | Get the permission, or use a different account |
| 401 Unauthorized | I do not know who you are | Send valid credentials |
| 404 Not Found | Nothing here (or nothing I will admit to) | Check the URL |
| 405 Method Not Allowed | Not with that method, for anyone | Use a method listed in Allow |
When choosing on the server side: use 401 if logging in could change the outcome, 403 if it could not, and 404 if even the existence of the resource is private.
Example 403 response
HTTP/1.1 403 Forbidden
Content-Type: application/json
Content-Length: 82
{"error":"insufficient_scope","message":"This token needs the orders:write scope"}Naming the missing scope turns a dead end into something the caller can act on. Leave the detail out where it would reveal more than the caller should know.
Defined in RFC 9110, section 15.5.4.
Questions
How do I fix a 403 Forbidden error on a website I am visiting?
Check that the URL points at a page and not a bare directory, sign in if the site has accounts, and turn off any VPN or proxy in case its address is blocked. If none of that helps, the restriction is on the site's side and only its owner can lift it.
Why does nginx return 403 for my site root?
Either the directory has no index file and directory listing is off, which the error log reports as "directory index of ... is forbidden", or the nginx user cannot read the files or traverse a parent directory, reported as "Permission denied".
Should an API return 403 or 404 for a resource the user may not see?
Use 403 when it is fine for the caller to know the resource exists. Use 404 when existence itself is sensitive, such as another customer's private data. The HTTP specification explicitly allows 404 for that purpose.
Does logging in again fix a 403?
Not with the same account. A 403 means the server refuses the request for the identity it sees, or for reasons unrelated to identity. Only a different account, an added permission or a change on the server alters the result.