EACCES in Node.js — What It Means and How to Fix It
What the Node.js/npm error EACCES means and how to resolve it.
Published October 24, 2026
EACCES means the process lacks permission to access a file, directory or port.
What it means and why it happens
Typical causes: writing to protected folders, running npm with global installs as a normal user, or binding to ports below 1024.
Read the full message: it names the file and line where the problem was detected, which is the best place to start.
What you see
run the code
Error: EACCES: permission denied, open '/var/log/app.log'
Practical examples
Code that triggers it
fs.writeFileSync('/var/log/app.log', 'x')The fix
fs.writeFileSync(path.join(os.tmpdir(), 'app.log'), 'x')Fix npm global permissions
mkdir ~/.npm-global
npm config set prefix ~/.npm-global
export PATH=~/.npm-global/bin:$PATHCommon mistakes
- Fixing with sudo npm install -g.
- Binding to port 80 as a normal user.
- Wrong ownership of project folders.
Key takeaways
- EACCES: EACCES means the process lacks permission to access a file, directory or port.
- Read the message and the line number first.
- Fix the cause, don't just silence the error.
FAQ
Port 80 without root?
Use a reverse proxy or setcap cap_net_bind_service.
How do I find which line caused EACCES?
The error message and stack trace show the file and line; start there and work backwards.