Q:

Node.js Unhandled 'error' event when using http.createServer().listen() on Ubuntu 12.04

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.

A:

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

A:

You probably have apache running on port 80, so it's conflicting.
Use another port (NOT within 0-1023), or disable apache.
Cheers

