Skip to content

403 Forbidden — Meaning, Common Causes & How to Fix

403 4xx Client Error RFC 9110 §15.5.4

403 Forbidden means: The server understood the request but refuses to authorize it. Unlike 401, re-authenticating will not help: the credentials (if any) are known and the answer is still no. Servers may also use 403 to hide the existence of a resource. Client-error 4xx codes mean the request itself is the problem: malformed syntax, missing credentials, forbidden access, a nonexistent resource or a violated precondition. The server is telling the client what to change; retrying the identical request without a fix will reproduce the same error. In practice you will meet 403 when an authenticated user lacks the role/permission for the operation; ip allowlists, waf rules or geo-blocking reject the request; file-system permissions or hotlink protection block access. On the client side, verify the account's permissions and scopes; if access should exist, contact the resource owner — retrying with the same identity will not change the outcome. On the server side, use 403 for authorization failures and consider returning 404 instead when revealing existence is itself sensitive; log the denial reason server-side.

Advertisement
Ad slot · ref-top

When 403 happens

  • An authenticated user lacks the role/permission for the operation
  • IP allowlists, WAF rules or geo-blocking reject the request
  • File-system permissions or hotlink protection block access

How to fix it

On the client

Verify the account's permissions and scopes; if access should exist, contact the resource owner — retrying with the same identity will not change the outcome.

On the server

Use 403 for authorization failures and consider returning 404 instead when revealing existence is itself sensitive; log the denial reason server-side.

Should you retry?

Not retryable as-is: change the request (credentials, payload, URL) first.

Debugging steps

When 403 appears unexpectedly, start by capturing the full exchange: 'curl -i' or the browser DevTools Network tab shows the exact status line and response headers, which often carry the real explanation. Read the error body first — well-designed APIs name the offending field or missing credential. Then diff your actual request, headers included, against the documented contract. For this code specifically, check whether the most common trigger applies to your situation: an authenticated user lacks the role/permission for the operation. Compare your exchange against the raw HTTP example above. If you operate the server, correlate the timestamp with application and proxy logs using the request id; if you are the client, verify the request shape against the API documentation before changing anything or retrying.

Notes & gotchas

403 is also the standard answer for WAF blocks, hotlink protection and IP denylists, so a sudden fleet-wide 403 often means an edge security rule changed rather than your permissions.

Examples

Raw HTTP
HTTP/1.1 403 Forbidden
Content-Type: application/json
Content-Length: 108

{
  "error": "forbidden",
  "message": "An authenticated user lacks the role/permission for the operation"
}
curl
curl -i https://api.example.com/v1/resource   # observe the 403 response and its headers
JavaScript (fetch)
const res = await fetch("https://api.example.com/v1/resource");
if (res.status === 403) {
  const problem = await res.json(); // read field-level details
  // fix the request (credentials, payload, URL) — identical retries keep failing
  throw new RequestError(problem);
}
Python (requests)
import requests

res = requests.get("https://api.example.com/v1/resource", timeout=10)
if res.status_code == 403:
    problem = res.json()  # field-level error details
    # correct the request before retrying — identical retries keep failing
    raise RequestProblem(problem)

Frequently asked questions

Can I retry my way out of a 403?

Not with the same identity and request. 403 is a policy decision; only changed permissions, a different account, or a different request shape can succeed.

Why does GitHub return 404 for private repos I cannot see?

To avoid leaking existence. 403 would confirm the resource exists; 404 keeps that information hidden from unauthorized callers.

Are 4xx errors always the client's fault?

By contract yes — the server asserts the request must change. In practice servers sometimes misuse 4xx for their own problems (e.g. 400 for internal validation bugs), so read the error body before blaming your client code.

Should I retry 4xx responses automatically?

Generally no: the server says the request must change. Exceptions are 408 (fresh connection), 425 (after handshake) and 429 (after Retry-After). Blind retries of 400/401/403/404 just burn quota.

Advertisement
Ad slot · ref-in-article

Try the JSON Validator

Check JSON syntax and locate errors by line and column.

Open tool →