Linux: Permission denied

Your user (or the service user) lacks read/write/execute permission on a file, directory or one of its parents.

Exact message you may see Permission deniedOperation not permitted
Seen on: Linux

Meaning

Linux checks permissions for the effective user on the file and requires execute (x) on every parent directory to traverse into it. Web servers run as www-data/nginx, not as you.

Common causes

  • File not readable/writable by the process user
  • Script missing execute bit (./script.sh: Permission denied)
  • Parent directory missing x permission
  • Files created by root via sudo
  • SELinux/AppArmor denying access
  • Filesystem mounted noexec

⚡ Quick fix

  1. ls -l file and namei -l /full/path to inspect permissions
  2. chmod +x script.sh for scripts
  3. sudo chown -R user:group dir to fix ownership
  4. Check SELinux: getenforce, ls -Z, audit2why

Detailed fix by platform

Linux

  1. Typical web app permissions:
    bash
    sudo chown -R www-data:www-data /var/www/app/storage
    sudo find /var/www/app -type d -exec chmod 755 {} \;
    sudo find /var/www/app -type f -exec chmod 644 {} \;
  2. Avoid chmod 777 — it fixes the symptom and creates a security hole.

How to diagnose

  1. User — Which user runs the process (ps aux)?
  2. Path — namei -l along the full path
  3. MAC — SELinux/AppArmor denials?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

0x80070005 — Windows Error 0x80070005 (E_ACCESSDENIED): Access is denied (Windows)0x80070005403 — HTTP 403 Forbidden (HTTP)40342501 — PostgreSQL: ERROR: permission denied for table / schema public (PostgreSQL)42501Access to the path is denied — System.UnauthorizedAccessException: Access to the path 'x' is denied (.NET)Access to the path is…AccessDeniedException — java.nio.file.AccessDeniedException: /path (Java)AccessDeniedExceptionavc: denied — SELinux is preventing ... / avc: denied { read } for pid=... (permission denied despite correct permissions) (Linux)avc: deniedcommand not found — bash: command not found (Linux)command not founddaemon — Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (Docker)daemonEACCES

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.