Skip to main content

HTTP · 6 common causes

403 Forbidden

Updated

The server knows who you are and is refusing anyway — this is about permission, not identity.

The exact message

$ curl -i https://api.example.com/v1/admin/users
HTTP/1.1 403 Forbidden
content-type: application/json

{"error":"insufficient_scope","required":"users:read"}

Paths, line numbers and stack frames differ on every machine, and the wording is tightened between versions. The part that identifies the problem is 403 Forbidden.

How to fix it

Cause 1 of 6

The credential lacks the required role, scope or plan.

Compare the token's scopes against what the endpoint requires — the response body usually names the missing one. Scopes are fixed when a token is issued, so refreshing an old token does not add them; you have to request a new one with the right scopes.

Cause 2 of 6

The resource belongs to someone else.

Object-level authorisation is separate from route-level. Confirm the id belongs to the authenticated account or organisation — cross-tenant reads returning 403 is the system working correctly.

Cause 3 of 6

A WAF, CDN or bot rule blocked the request before it reached the app.

Cloudflare, AWS WAF and similar return their own 403 with a distinctive body and headers such as cf-ray. That is a rule change, not a code change — and a missing or unusual User-Agent triggers a surprising number of them.

Cause 4 of 6

A static file server cannot read the path.

nginx and Apache return 403 for a directory with no index file, or a file the worker user cannot read. Check the server's error log for the exact path, and set files to 644 and directories to 755 — never 777, which makes them writable by every account on the machine.

Cause 5 of 6

A CSRF token is missing or stale.

Django, Rails and Laravel reject unsafe methods without a valid token, and Django's 403 page says so explicitly. Send the token from the cookie or meta tag in the header the framework expects, and refresh it when the session rotates.

Cause 6 of 6

Object storage denies by policy.

S3 and equivalents return 403 for both a denied action and a missing object when listing is not permitted, which makes them hard to tell apart. Check the bucket policy, the IAM policy and any block-public-access setting together, since a deny in any of them wins.

Stopping it coming back

Return a body that names the required permission when you deny a request — it turns a support ticket into a self-service fix — and test authorisation with a token that deliberately lacks the scope.

403 Forbidden — common questions

Should a missing resource return 403 or 404?
If revealing existence is itself a leak — another tenant's record, a private repository — 404 is the safer answer and many APIs use it deliberately. Within a tenant, 403 is more useful because it tells the caller the thing exists and they lack rights to it.
Why does the same request work in curl but not the browser?
Usually a WAF rule keyed on headers, or a CSRF check the browser request triggers and curl does not. Compare the two request header sets in full — the difference is normally in Origin, Referer, User-Agent or a cookie.
Is retrying a 403 useful?
No. Unlike 429 or 503, a 403 is a decision, not a temporary state. Retrying wastes quota and can trip rate limiting; fix the permission instead.

Test the fix before you paste it back

Reproducing the failure in a scratch file is usually faster than editing the real one. AltF Code is a free in-browser editor with real syntax highlighting for HTML, CSS, JavaScript, TypeScript, Python, SQL and JSON, and it runs HTML, CSS and JavaScript live in a preview panel. No install and no sign-up.

Open the editor