6

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.

1

6 Answers 6

13

On Ubuntu you can't listen on ports < 1024 without root privileges. Try running node under sudo.

sudo node app.js
1
  • I don't know whether this would be recommendable on a production system though.
    – Luc Morin
    Commented Nov 5, 2013 at 7:44
7

You probably have apache running on port 80, so it's conflicting.

Use another port (NOT within 0-1023), or disable apache.

Cheers

1
  • 1
    Yep. Anytime you see that ol' Error: listen EACCES you can bet that you're either fighting for permissions or fighting with another app for the port.
    – ChevCast
    Commented Nov 4, 2013 at 1:30
1

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/

  1. Usually it means another server like apache is enabled. so stop it.

    sudo service apache2 stop

  2. or You have npm start already running in another terminal

  3. 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

  4. or use another port

    http-server -a localhost -p 8000

0

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.

0

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!

0

I was able to rectify the error by explicitely mentionining the "IP address" along with the port when listening to the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.