nginx.ccWeb server troubleshooting desk
Home / Errors / 403
403

Nginx 403 Forbidden: causes and fixes

Short answer

403 usually means no index file in a directory, file permissions nginx cannot read, a deny rule, or SELinux. Check whether error.log says “directory index forbidden” or “Permission denied”.

Most common cause: A directory was requested with no file matching index, and autoindex is off.

Try this first: Add index or use try_files

root /var/www/site;
index index.html index.php;
location / {
    try_files $uri $uri/ =404;   # 404 instead of 403 when there is no index
}

Last verified: · against the official docs listed below · Sources

Typical log lines

directory index of "/var/www/site/" is forbidden
open() "/var/www/site/index.html" failed (13: Permission denied)
access forbidden by rule

Common causes

  1. A directory was requested with no file matching index, and autoindex is off.
  2. The nginx user (www-data / nginx) lacks read/execute permission on the file or any parent directory.
  3. Site lives under /root or /home/user whose permissions are 700.
  4. A deny all / allow rule or auth matched.
  5. Wrong SELinux file context (not httpd_sys_content_t).

Diagnosis commands

index forbidden vs Permission denied
#tail -n 20 /var/log/nginx/error.log
Permissions of every path component
#namei -l /var/www/site/index.html
Read as the nginx user (use nginx on RHEL)
#sudo -u www-data cat /var/www/site/index.html >/dev/null && echo ok
SELinux context
#ls -Z /var/www/site

Fix configs

Add index or use try_files

root /var/www/site;
index index.html index.php;
location / {
    try_files $uri $uri/ =404;   # 404 instead of 403 when there is no index
}

Fix permissions

chown -R www-data:www-data /var/www/site     # nginx:nginx on RHEL
find /var/www/site -type d -exec chmod 755 {} +
find /var/www/site -type f -exec chmod 644 {} +

SELinux context

semanage fcontext -a -t httpd_sys_content_t '/var/www/site(/.*)?'
restorecon -Rv /var/www/site

Run nginx -t first, then systemctl reload nginx.

Key facts and sources

  • index checks the listed files in order; the default is only index.html (PHP sites must add index.php). [nginx.org]
  • allow / deny rules are checked in order until the first match. [nginx.org]

Checked against the linked pages on 2026-11-14; the official docs win if a newer nginx changes them.

FAQ

Will chmod 777 fix 403?

Sometimes, but it is dangerous: any process can modify your site. Use 755 for dirs, 644 for files, owned by the deploy or nginx user.

Why is a site under /root always 403?

/root is 700, so the nginx user cannot even enter it. Move the site to /var/www.

Fix it with a tool

Related errors

Sponsored slot (empty)
VPS / CDN recommendations may appear here later, labelled as affiliate links. There are no referral links today.