Nodejs throws an error when listening to the port under Linux

june@june-Satellite-C600:~/nodejs/lesson$noderandom.js
RandomNumberGeneratorRunning…

events.js:72
thrower;//Unhandled'error'event
^
Error:listenEACCES
aterrnoException(net.js:904:11)
atServer._listen2(net.js:1023:19)
atlisten(net.js:1064:10)
atServer.listen(net.js:1138:5)
atObject.<anonymous>(/home/june/nodejs/lesson/random.js:50:8)
atModule._compile(module.js:456:26)
atObject.Module._extensions..js(module.js:474:10)
atModule.load(module.js:356:32)
atFunction.Module._load(module.js:312:12)
atFunction.Module.runMain(module.js:497:10)

There are two ways to solve the problem

1:sudo node *.js —–> Root authority solution

2: Set the port number above 1024 in the code; Because Linux monitors & lt; 1024 port needs root permission, > No need

Similar Posts: