“node index.js” when Node server error (EADDRINUSE)… here is a solution to the problem.
“node index.js” when Node server error (EADDRINUSE)
On Mint Maya 64, I get this error if I run “node index.js” (v0.10.21) in the terminal:
events.js:72
throw er; Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:901:11)
at Server._listen2 (net.js:1039:14)
at listen (net.js:1061:10)
at Server.listen (net.js:1127:5)
at Object.<anonymous> (/home/USER/Desktop/server/index.js:73:24)
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)
at Function.Module.runMain (module.js:497:10)
My apache2 server is stopped and no other Node servers are running.
I tried “killall node” -> node: no process found
With “sudo netstat -tulpn”, there is no indication of any listening on port 80.
Because this is my first Node server experiment, I don’t know how.
Solution
First check the port used by Node in your index.js file.
There is another application that uses this port.
So you have two options:
- Terminate the app
- Use a different port for the Node app