Qaynaq LABS · TOOLS

HTTP · 4xx Client Error

403 Forbidden

Server refuses to fulfill the request due to lack of authorization or permission.

When you see this status

  • User lacks required permissions for a resource
  • API key or token is missing/invalid
  • Rate limiting or IP blocking is enforced
  • CSRF token validation fails
  • CORS policy blocks the request origin

Common causes

  • Missing or invalid authentication credentials
  • Insufficient user privileges
  • Server-side access control misconfiguration
  • Request origin not whitelisted
  • Exceeded API rate limits

How to debug it

  1. Verify user credentials and permissions
  2. Check server access control rules
  3. Inspect request headers for auth tokens
  4. Review server logs for access violations
  5. Test with elevated privileges

Return this code in your framework

Express (Node.js)
res.status(403).send('Forbidden');
FastAPI (Python)
return JSONResponse(status_code=403, content={"detail": "Forbidden"})
NestJS
@Get() @UseGuards(AuthGuard) forbidden() { throw new ForbiddenException(); }
Go (net/http)
http.Error(w, "Forbidden", http.StatusForbidden)

About HTTP 403

HTTP status code 403 Forbidden is part of the 4xx Client Error family. Server refuses to fulfill the request due to lack of authorization or permission. Understanding it is essential for backend engineers, API designers, and anyone debugging integrations between services.

The Qaynaq Labs HTTP Status Code Explainer covers all standard codes with practical guidance: what triggers them, how to debug them in production, and exactly how to return them from common frameworks. Each code page is hand-curated and verified.

Frequently asked

Is 403 returned when credentials are missing?

No, 401 Unauthorized is returned when authentication is required but missing. 403 indicates authentication succeeded but authorization failed.

Can a 403 response include a body?

Yes, though clients should not rely on it. Servers may include details about access restrictions in the response body.

How to differentiate between 403 and 401 in logs?

Check response headers for WWW-Authenticate (401) or inspect server-side authorization logic (403).

Should 403 responses be cached?

No. 403 indicates dynamic authorization decisions that may change per request.