G
G
greatte2017-04-05 23:48:09
Node.js
greatte, 2017-04-05 23:48:09

Why doesn't pm2 start without root rights?

Faced a popular problem in pm2, without root, scripts do not run. After the reboot, I performed
sudo chown -R node:node .pm2/
some of the files on which the user and the "root" group stood, returned to these parameters, but before the reboot everything worked fine. Here is the actual error:

[email protected]:~$ pm2 list
events.js:141
 throw er; // Unhandled 'error' event
  ^

Error: connect EACCES /home/node/.pm2/rpc.sock
 at Object.exports._errnoException (util.js:870:11)
 at exports._exceptionWithHostPort (util.js:893:20)
 at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1063:14)

Here are the current owners and groups, which, when changed after a reboot, return to this view:
-rw-rw-r-- 1 node node     5310 Apr  4 10:17 dump.pm2
drwxrwxr-x 2 node node     4096 Apr  3 14:06 logs
-rw-rw-r-- 1 node node        2 Apr  1 16:07 module_conf.json
drwxrwxr-x 2 node node     4096 Apr  4 14:15 pids
-rw-rw-r-- 1 node node 38052371 Apr  4 14:15 pm2.log
-rw-r--r-- 1 root root        3 Apr  4 14:14 pm2.pid
srwxr-xr-x 1 root root        0 Apr  4 14:14 pub.sock
srwxr-xr-x 1 root root        0 Apr  4 14:14 rpc.sock
-rw-rw-r-- 1 node node       13 Apr  1 16:07 touch

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
de1m, 2017-04-06
@de1m

here, in my opinion, there can be two reasons
1. The error says that it cannot connect to /home/node/.pm2/rpc.sock and below in your rights it says that only root can. Try to change the permissions manually to "node:node" for rpc.sock before starting.
2. If you open a network port up to 1024 somewhere in the script, then you need root rights.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question