Reputation: 6710
Salam (means Hello) :)
I've developed a node.js script on my windows seven machine and it's working fine. but when I run it on my Ubuntu 12.04, the following error shows up and halts my app:
throw er; // Unhandled 'error' event
^
Error: listen EACCES
at errnoException (net.js:901:11)
at Server._listen2 (net.js:1020:19)
at listen (net.js:1061:10)
at Server.listen (net.js:1127:5)
at Object.start (/httpServer/httpServer.js:9:34)
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)
and the point that caused error is .listen(80)
in this line:
http.createServer(onRequest).listen(80);
^
I've also tried some other port numbers (like 100, 300, 500,...) instead of 80
and the error was still the same.
Upvotes: 6
Views: 4639
Reputation: 38352
You probably have something else running on port 80, so it's conflicting.
Read here to find out what is using port 80 and stop it http://www.cyberciti.biz/faq/find-linux-what-running-on-port-80-command/
Usually it means another server like apache is enabled. so stop it.
sudo service apache2 stop
or You have npm start
already running in another terminal
or skype is running. in which case go to settings and change it's port. logout n login
Go to Tools -> Options -> Advanced -> Connections and uncheck the box "use port 80 and 443 as alternative".src
or use another port
http-server -a localhost -p 8000
Upvotes: 1
Reputation: 191
I was able to rectify the error by explicitely mentionining the "IP address" along with the port when listening to the server.
Upvotes: 0
Reputation: 1524
This can also be caused if you have something else already listening on that port - you can try changing the port from the typical default 80 to something more like 10014 and see if that helps!
Upvotes: 0
Reputation: 3133
On Ubuntu you can't listen on ports < 1024 without root privileges. Try running node under sudo.
sudo node app.js
Upvotes: 13
Reputation: 5380
You probably have apache running on port 80, so it's conflicting.
Use another port (NOT within 0-1023), or disable apache.
Cheers
Upvotes: 7
Reputation: 2909
I suggest to install the latest node packets, maybe directly from Node.js server, maybe compiling it.
Try to set a port which is not reserved to any service, like 3700.
Could be heplful to see some other fragment of code, though.
Upvotes: 0