Home / Localhost / nginx 403 Forbidden

nginx 403 Forbidden: permissions, index file and root folder

Fix nginx 403 Forbidden: check the folder permissions, the index file, the root path and SELinux.

A 403 Forbidden from nginx means nginx found the path but may not serve it. The usual causes are file permissions, a missing index file, or a wrong root folder. The error log names the cause.

What to do, step by step

  1. Read the log: sudo tail -n 20 /var/log/nginx/error.log.
  2. If it says directory index of "…" is forbidden, the folder has no index file. Add index.html or index.php, or fix the index line.
  3. If it says (13: Permission denied), nginx's user cannot read the path. Check every folder on the way with namei -l /var/www/mysite/index.html.
  4. Give read access: folders need execute for others (chmod 755), files need read (chmod 644).
  5. Confirm the root path in your server block points at the folder that holds your files.

Commands you can copy

Show permissions of every folder on the path
namei -l /var/www/mysite/index.html
Set common permissions on a site folder
sudo find /var/www/mysite -type d -exec chmod 755 {} \;
sudo find /var/www/mysite -type f -exec chmod 644 {} \;

Other causes to check

Files are in a home folder
nginx's user cannot enter /home/you by default. Move the site to /var/www, or allow access to the folder with chmod or ACLs.
Works for root but not for the web user
Check which user nginx runs as with the user line in nginx.conf (often www-data or nginx) and make that user own or read the files.
SELinux is on (Fedora, CentOS, Rocky)
Set the right label: sudo chcon -R -t httpd_sys_content_t /var/www/mysite.
403 only for one folder with autoindex
A directory with no index file needs autoindex on; to show a list. It is off by default.

Questions about nginx 403 Forbidden

What does "directory index is forbidden" mean?
The URL points to a folder, and there is no index file inside it. Add one, or turn on autoindex if you really want a file list.
What permissions should web files have?
Usually 644 for files and 755 for folders, owned by you or the web user. Never use 777 on a server.
Why do I get 403 on a PHP site?
The index line may not include index.php, or the PHP-FPM block is missing. See the nginx PHP-FPM page.

Updated 2026-10-11

Config generators for this

Related pages