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

nginx (13: Permission denied): troubleshooting

Short answer

13: Permission denied appears when reading files, connecting to a socket, writing logs or binding ports: the worker user lacks rights, a parent dir is not traversable, the socket owner is wrong, or SELinux blocks it.

Most common cause: Site under /home/user or /root without execute permission on parents.

Try this first: Make parents traversable

chmod o+x /home/deploy /home/deploy/site
# better: keep sites under /var/www, owned by the deploy user, group www-data

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

Typical log lines

open() "/home/deploy/site/index.html" failed (13: Permission denied)
connect() to unix:/run/php/php8.3-fpm.sock failed (13: Permission denied) while connecting to upstream
bind() to 0.0.0.0:80 failed (13: Permission denied)
open() "/var/log/nginx/access.log" failed (13: Permission denied)

Common causes

  1. Site under /home/user or /root without execute permission on parents.
  2. PHP-FPM socket listen.owner/listen.group is not the nginx user.
  3. Running nginx as non-root while binding ports below 1024.
  4. SELinux blocks reading non-standard dirs or connecting to sockets.

Diagnosis commands

Which user the workers run as
#ps -o user= -C nginx | sort | uniq -c
Permissions per path component
#namei -l /home/deploy/site/index.html
Socket owner
#ls -l /run/php/*.sock
SELinux denials
#ausearch -m avc -ts recent | tail

Fix configs

Make parents traversable

chmod o+x /home/deploy /home/deploy/site
# better: keep sites under /var/www, owned by the deploy user, group www-data

PHP-FPM socket owner

; /etc/php/8.3/fpm/pool.d/www.conf
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
; on RHEL use nginx, then restart php-fpm

SELinux

semanage fcontext -a -t httpd_sys_content_t '/srv/site(/.*)?'
restorecon -Rv /srv/site
setsebool -P httpd_can_network_connect 1   # when nginx must connect to backend ports

Run nginx -t first, then systemctl reload nginx.

Key facts and sources

  • Workers run with the user and group named by the user directive (default nobody nobody), so check that line at the top of nginx.conf. [nginx.org]

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

FAQ

Can I just set user root?

No. Root workers turn any bug into full host compromise. Fix file and socket permissions instead.

Will chmod -R 777 fix it?

Don't. 777 lets any user modify your files. Give the nginx user x on every directory in the path and r on the files (typically 755 / 644) and check each level with namei -l.

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.