Error Encyclopedia

EACCES: Permission Denied Error

Fix 'EACCES: permission denied' errors in Node.js and Linux. Learn how to fix file permission, port binding, and npm global install issues.

What Does This Error Mean?

The EACCES error means the application does not have sufficient permissions to access a file, directory, or resource. This is a file system or operating system permission error, not an HTTP 403.

Common Causes

1

Trying to bind to a privileged port (below 1024) without root

2

npm global install without sudo on Linux/macOS

3

File or directory permissions set too restrictively

4

Running Node.js as a different user than the file owner

5

SELinux or AppArmor blocking access

6

Read-only file system (e.g., container without write permissions)

How to Fix It

Use ports above 1024 and proxy

Run your app on a high port and use Nginx as a reverse proxy on port 80/443.

# Run app on port 3000 instead of 80
PORT=3000 node app.js

# Nginx reverse proxy to forward port 80 to 3000
server {
  listen 80;
  location / {
    proxy_pass http://localhost:3000;
  }
}

Fix npm global permissions

Configure npm to use a local directory for global packages instead of /usr.

# Option 1: Change npm prefix
mkdir ~/.npm-global
npm config set prefix "~/.npm-global"
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc

# Option 2: Use nvm (recommended)
# nvm manages Node.js without sudo

Fix file permissions

Use chmod to grant appropriate file permissions.

# Make file readable and writable by owner
chmod 644 file.txt

# Make directory executable (traversable)
chmod 755 directory

# Change ownership
sudo chown -R $(whoami) /path/to/project

Related Tools

Use these tools to debug and fix this error:

Related Errors

Other common errors in this category: