Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing a node application and encountering an error when running 'node server.js'

Tags:

node.js

I'm writing a node application and I recently switched from port 3000 to port 80 on my Mac Os X Lion machine (running 10.7.4) and whenever I run node server.js I get the following error

events.js:66
    throw arguments[1]; // Unhandled 'error' event
                   ^
Error: listen EACCES
    at errnoException (net.js:768:11)
    at HTTPServer.Server._listen2 (net.js:891:19)
    at listen (net.js:935:10)
    at HTTPServer.Server.listen (net.js:984:5)
    at Object.<anonymous> (/Users/ajain/Documents/Projects/Time-Feed/server.js:127:5)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)

Any idea on what I have to do to fix the issue?

like image 742
mosquito242 Avatar asked Aug 26 '12 02:08

mosquito242


1 Answers

You need to have the root privilege in order to listen on a port number below 1024. Therefore, you may use the sudo command.

sudo node server.js  
like image 62
qiao Avatar answered Sep 21 '22 20:09

qiao