403
Forbidden
4xx Client Error

What Does HTTP 403 Forbidden Mean?

HTTP 403 Forbidden means the server understood the request but refuses to authorize it. Unlike 401 (which means "authenticate yourself"), 403 means "I know who you are, and you are not allowed to do this." Re-authenticating with the same credentials will not help.

The server may or may not explain the reason in the response body. In many cases, 403 is a catch-all for "access denied" covering file permissions, IP restrictions, WAF blocks, role-based access control, and more.

Common Causes

How to Fix It

For Server Administrators

# Check and fix file permissions (Linux/macOS) # Files should be 644, directories should be 755 # Check current permissions ls -la /var/www/html/ # Fix file permissions find /var/www/html -type f -exec chmod 644 {} \; # Fix directory permissions find /var/www/html -type d -exec chmod 755 {} \; # Fix ownership (Nginx example) chown -R www-data:www-data /var/www/html/ # Fix ownership (Apache example) chown -R apache:apache /var/www/html/

Nginx: Allow Directory Listing

# If you want to allow directory listing location /files/ { autoindex on; } # Or ensure an index file exists location / { index index.html index.htm; }

Apache: Check .htaccess

# Common .htaccess rules that cause 403 # This blocks all access: # Deny from all # Fix: Allow access Order deny,allow Allow from all # Modern Apache 2.4 syntax: <Directory /var/www/html> Require all granted </Directory>

For API Developers

// Express.js - Role-based access control const requireRole = (role) => (req, res, next) => { if (!req.user) { return res.status(401).json({ error: 'Authentication required' }); } if (req.user.role !== role) { return res.status(403).json({ error: 'Insufficient permissions', required_role: role, your_role: req.user.role }); } next(); }; app.delete('/api/users/:id', requireRole('admin'), (req, res) => { // Only admins reach here });

403 vs 404: Security Considerations

Returning 403 reveals that the resource exists but is not accessible. In some cases, this leaks information:

GitHub uses this pattern: if you do not have access to a private repository, you see a 404, not a 403. This prevents outsiders from learning which repositories exist.

Frequently Asked Questions

What causes a 403 Forbidden error?
The most common causes are: incorrect file permissions on the server (the web server user cannot read the files), .htaccess or Nginx rules blocking access, a WAF or security module blocking the request based on its content or origin, IP address or geographic restrictions, directory listing being disabled with no index file present, or application-level access control denying the request based on user roles.
How do I fix a 403 error on my website?
Start by checking file permissions: files should be 644 and directories 755. Verify ownership matches the web server user (www-data, apache, etc.). Check .htaccess for Deny from all rules. Look at server error logs for specifics. If you use a CDN or WAF (Cloudflare, AWS WAF), check its logs for blocked requests. For users: clear cache, try incognito mode, disable VPN, or try from a different network.
Should I return 403 or 404 for unauthorized access?
For security-sensitive resources, return 404 to hide the resource's existence. For public APIs with clear permission models, 403 with an informative error message is more developer-friendly. GitHub, for example, returns 404 for private repos you cannot access — this prevents enumeration attacks. Choose based on your threat model.

Related Status Codes

Related Tools