Friday, April 8, 2022

[SOLVED] node server error when "node index.js" (EADDRINUSE)

Issue

On Mint Maya 64, if I run "node index.js" (v0.10.21) in terminal, I get this error:

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 there is no other node server running.

I tried "killall node" -> node: no process found

With "sudo netstat -tulpn" there is no sign of anything listening on port 80.

Because it's the first node server experiment for me, I don't have a clue how to proceed.


Solution

Check which port is used by Node in your index.js file, for a start. There is another application which uses this port. So you have two options:

  • kill this app
  • use another port for Node app


Answered By - Andrei Karpushonak
Answer Checked By - Candace Johnson (WPSolving Volunteer)