Error: EACCES, Permission denied - When using forever

2,818 views
Skip to first unread message

kcar

unread,
Oct 31, 2011, 12:39:54 PM10/31/11
to nodejs
I am running nodejs on an Amazon EC2 instance without root user
access. I therefore use 'sudo' to run nodejs.

However when I try and fun my nodejs server with Forever usuing 'sudo'
like this:
"sudo forever start -c node app.js"

I get this error:
"/usr/bin/env: node: No such file or directory"

Without using 'sudo' with Forever, I get this error in my log file:
"node.js:134
throw e; // process.nextTick error, or 'error' event on first
tick
^
Error: EACCES, Permission denied
at Server._doListen (net.js:1100:5)
at net.js:1071:14
at Object.lookup (dns.js:153:45)
at Server.listen (net.js:1065:20)
at Object.<anonymous> (/home/hosts.js:13:4)
at Module._compile (module.js:407:26)
at Object..js (module.js:413:10)
at Module.load (module.js:339:31)
at Function._load (module.js:298:12)
at Array.<anonymous> (module.js:426:10)"

What is the best way to run a nodejs server using forever and sudo?

Amazon EC2 Instance - Basic Linux - 64bit.

Ben Noordhuis

unread,
Oct 31, 2011, 6:16:44 PM10/31/11
to nod...@googlegroups.com

You probably shouldn't run Node as root. Either use authbind or
forward traffic from port 80 to some unprivileged port and have your
app listen on that. Example:

$ sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT
--to-port 8080
$ forever start -c node app.js

Reply all
Reply to author
Forward
0 new messages