← Knowledge Base
TroubleshootingReference note1 min read · updated 2026-11-27

Troubleshooting: "Permission denied" and 403 errors

Check ownership, mode, parent directories, SELinux/AppArmor and who the process runs as.

permissions403troubleshooting
ls -ld /path /path/to /path/to/file      # every parent directory needs x for the user
namei -l /path/to/file                   # shows owner and mode of each path component
ps -o user,cmd -C nginx                  # which user does the process run as?
sudo -u www-data cat /path/to/file       # try as that user
id; groups
getenforce 2>/dev/null; sudo aa-status 2>/dev/null | head   # SELinux / AppArmor

A web server that returns 403 usually cannot traverse a directory (missing x on a parent) or read a file; fix with chmod -R a+rX site/ for public content. After copying files from another system, owners and modes are often wrong. In containers the user ID inside the container must match the owner of the mounted files. If everything looks right, a mandatory access control system (SELinux, AppArmor) or a read-only mount may be blocking it.