EACCES, permission denied
Each time I try to start an app, I get this. No idea what I should adjust in the user permissions.
I am running pm2 with the right user nodejs who owns the home directory.
fs.js:427
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EACCES, permission denied '/home/nodejs/.pm2/pids/www.signora.co.nz.pid10.pid'
at Object.fs.openSync (fs.js:427:18)
at Object.fs.writeFileSync (fs.js:966:15)
at ProcessContainer (/opt/node-0.10.28/lib/node_modules/pm2/lib/ProcessContainer.js:30:6)
at Object.<anonymous> (/opt/node-0.10.28/lib/node_modules/pm2/lib/ProcessContainer.js:44:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
got same problem
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^Error: EACCES, permission denied '/home/deploy/.pm2/pids/api.pid16.pid'
at Object.fs.openSync (fs.js:427:18) at Object.fs.writeFileSync (fs.js:966:15)
at ProcessContainer (/usr/local/node/lib/node_modules/pm2/lib/ProcessContainer.js:30:6)
at Object.<anonymous> (/usr/local/node/lib/node_modules/pm2/lib/ProcessContainer.js:44:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
I was experiencing this same problem (on OS X), and the only "solution" was to open up permissions with sudo chmod -R 777 .pm2.
Is there a better solution to this issue?
What about a clean install:
pm2 kill
rm -r /usr/local/lib/node_modules/pm2 #or your pm2 install dir
rm -r ~/.pm2 #or your pm2 user home dir
npm i pm2 -g
Could you check me the ~/.pm2 rights for the running user (also ~/.pm2/pids)?
Thanks!
All good, I sorted this out myself few days ago. I was starting pm2 with the wrong user.
Same issue here - started pm2 as a different user by merely running pm2 l to see if any processes were running.
IMO this is a pm2 issue - it should specifically check the UID of the user running the daemon and complain if it's different from the current UID (or, actually, work).
@binarykitchen, think this should be reopened?
yeah, this would improve the usability of pm2
+1 Giving a check on the uid might prevent a lot of issues that are user-related (:
@soyuka 's comment pointed me to the right path.
I had previously installed pm2 globally, and then I was using it locally in an app. Turns out that my ~/.pm2 folder was only accessible to the root user (root created this folder when I was running pm2 globally). So I deleted ~/.pm2 folder, ran my script again, and everything worked perfectly this time.
Using WinSCP I SFTP logged-in as root, right click the file and changed it s Group & User to my user, then set Permmissions to 777 (666 will do if you only need read & write).
For me pm2 kill then pm2 start SERVER.JS worked for me.
I have the similar problem still pm2 version 4.5.6 on production but I am running as ecosystem.json and this is the code on that file
{
"apps": [
{
"name": "appname",
"script": "PORT=3002 node build",
"instances": 1,
"exec_mode": "fork"
}
]
}
rror: EACCES: permission denied, mkdir '/root/.pm2/logs'
at Object.mkdirSync (fs.js:1009:3)
at mkdirpNativeSync (/usr/lib/node_modules/pm2/node_modules/mkdirp/lib/mkdirp-native.js:29:10)
at Function.mkdirpSync [as sync] (/usr/lib/node_modules/pm2/node_modules/mkdirp/index.js:21:7)
at module.exports.Client.initFileStructure (/usr/lib/node_modules/pm2/lib/Client.js:133:25)
at new module.exports (/usr/lib/node_modules/pm2/lib/Client.js:38:8)
at new API (/usr/lib/node_modules/pm2/lib/API.js:108:19)
at Object.
Same problem, someone has solution ?
When I run pm2-dev start ./src/server.js no problem, but through npm cross-env NODE_PATH=./src pm2-dev start ./src/server.js doesn't work.
I am STILL HAVING THIS ISSUE on a new ubuntu Debian 11 installation
Error: EACCES: permission denied, mkdir '/root/.pm2/logs' Error: EACCES: permission denied, mkdir '/root/.pm2/pids' Error: EACCES: permission denied, open '/root/.pm2/module_conf.json Error: EACCES: permission denied, mkdir '/root/.pm2/modules'
I'm doing this within a docker container. While the primary init is running as root, the child process is running as the user node.
/usr/src/app # ps aux
PID USER TIME COMMAND
1 root 0:00 {docker-entrypoi} /bin/sh /usr/src/app/docker-entrypoint.dev.sh
7 root 0:00 npm run start:dev
18 node 0:00 node /usr/src/app/node_modules/.bin/cross-env NODE_PATH=. nodemon cluster.js
25 node 0:00 node /usr/src/app/node_modules/.bin/nodemon cluster.js
56 root 0:00 ash
68 root 0:00 ps aux
To fix this, I configured the environment variable PM2_HOME to something appropriate for my application, based on this comment.
Does someone know how this error impacts PM2?
I am STILL HAVING THIS ISSUE on a new ubuntu Debian 11 installation
Error: EACCES: permission denied, mkdir '/root/.pm2/logs' Error: EACCES: permission denied, mkdir '/root/.pm2/pids' Error: EACCES: permission denied, open '/root/.pm2/module_conf.json Error: EACCES: permission denied, mkdir '/root/.pm2/modules'
If you use sudo prefix, try taking it out
On windows10 ,pm2 read shared file error ,at first, According to the big guy's description,i resolve the permission error ,meanwhile On certain machines ,new error was found ,i try to fs.stat ,get the error desc is like errno: -4094, code: 'UNKNOWN', syscall: 'stat', who can tell me how to resolve it or the problem is about what,thanks