What a 403 Error Means
403 Forbidden means the server understood the request and refuses to serve it. It is not a login prompt: a 401 asks for credentials, while a 403 says the answer is no. In Nginx the refusal comes from the file system, the index settings, an access rule, or SELinux.
If You See It on Someone Else's Site
- Check the address: a folder address without a page name can be refused while the pages inside it work.
- Log in if the site has accounts: some applications answer 403 to visitors who are not signed in.
- Try another network: a site may block some address ranges or regions. If it persists, tell the site owner.
Read the Error Log
sudo tail -n 20 /var/log/nginx/error.logThe path is the same on Debian, Ubuntu, AlmaLinux, and Rocky Linux. Three messages cover most cases:
- Permission denied (13): Nginx cannot read the file or enter a folder on the way to it.
- Directory index is forbidden: the request was for a folder that has no index file.
- Access forbidden by rule: a
denyline matched the client.
Ownership and Permissions
Nginx workers run as www-data on Debian and Ubuntu and as nginx on AlmaLinux and Rocky Linux. They need read access to files and execute access to every folder on the path. namei shows each step:
namei -l /var/www/example.com/public/index.htmlSet the usual modes, 755 for folders and 644 for files:
sudo find /var/www/example.com -type d -exec chmod 755 {} \;
sudo find /var/www/example.com -type f -exec chmod 644 {} \;Never use 777 to make the error go away: it lets every user and process on the server change your site.
The Execute Bit on Parent Folders
A file with mode 644 stays unreadable if a folder above it lacks the execute bit for Nginx. This is the usual cause when a site lives in a home directory: recent Ubuntu releases create home directories with mode 750, and AlmaLinux and Rocky Linux with 700, so other users cannot enter them. Either move the site under /var/www, or let only the web server pass through:
sudo setfacl -m u:www-data:x /home/deployThe ACL lets www-data enter /home/deploy without listing or reading its other files; setfacl is in the acl package. Use u:nginx:x on the Red Hat family, where SELinux also blocks web content in home directories until it is labeled, as shown below. Moving the site to /var/www is usually simpler there.
Missing Index File and Autoindex
For a request that ends in a folder, Nginx looks for the files named in the index directive. If none exists and autoindex is off, which is the default, the answer is 403. Check the line and the actual file names:
index index.html index.php;For a PHP application, index.php must be in that list and PHP requests must reach PHP-FPM. Turn on autoindex on; only in a location you mean to publish as a file listing.
Deny and Allow Rules
sudo nginx -T | grep -nE 'deny|allow'nginx -T prints the whole active configuration, including included files. Rules are checked in order and the first match wins, so an allow for one address followed by deny all; blocks everyone else. A location that hides dotfiles can also block paths you need, such as /.well-known/ for certificate checks. Edit the rule, then test before reloading:
sudo nginx -t && sudo systemctl reload nginxSELinux on AlmaLinux and Rocky Linux
If permissions look right and the log still shows error 13, check the SELinux label. Files created outside /var/www, or moved there with mv, keep a label that Nginx may not read:
ls -Z /srv/example.com
sudo ausearch -m avc -ts recentLabel the folder as web content and apply the label:
sudo semanage fcontext -a -t httpd_sys_content_t "/srv/example.com(/.*)?"
sudo restorecon -Rv /srv/example.comDo not turn SELinux off to fix a 403. The correct label solves it and keeps the protection in place.
Confirm the Fix
curl -I https://example.com/The first line should read 200. If it now shows 404, Nginx can read the folder but the file is missing; see 404 Not Found. If it shows 500, a PHP error has taken over; see 500 Internal Server Error. Every code is listed in HTTP status codes explained.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations