Empowering you to understand your world

Node.js Troubleshooting: ‘Error: EACCES: permission denied, open…’

If you get a ‘permission denied’ error when trying to read a file in Node.js, it means that you don’t have permission to access the file and you’ll have to adjust your permissions so your app can access that file, move the file, or run that particular app as root. The best solution is dependent on what you’re doing and which file it is.

If the error looks like this, then you are unable to access the certificate file required for your Lets Encrypt HTTPS setup:

[Error: EACCES: permission denied, open '/etc/letsencrypt/live/.../cert.pem'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/etc/letsencrypt/live/.../cert.pem'

In the case of Let’s Encrypt, running the Node app as root does resolve the issue. However, you’ll have to consider the security implications of that before going ahead with it.

Subscribe to our newsletter
Get notified when new content is published