slevin
slevin

Reputation: 3896

Node 8 sudden EADDRINUSE error

I am using node 8.11.1 along with angular 6, locally on windows 10. In my node app.js I have

//SERVER LISTEN
app.listen(3000, ()=>{
  console.log('Server running on port 3000');
});

at the bottom and I run my node using nodemon.

I did not installed any program recently, and node/angular worked perfectly.

I did some editing on a query code in node, some minor editing and then copied some files to an external drive. I did not remove the files, I copied them, so they are still on my laptop too, I can see them. These are the last steps I can recall.

And yet, I do nodemon, now I get

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::3000

What happened ? Is there an explanation ? How can I get node to run on port 3000 again? Thanks

Upvotes: 1

Views: 90

Answers (2)

xan_z
xan_z

Reputation: 226

Try to find what is running on that port. You can search online on how to find what is running on your windows system. This post here can help. In fact I used the below command which I got from this post and it clearly showed me what was running on that port.

for /f "tokens=5" %a in ('netstat -aon ^| findstr <port>') do tasklist /FI "PID eq %a"

Get the PID from there, and you can use the next command to kill that process. Hope this helps.

Taskkill /PID <pid> /F

Upvotes: 1

Hiteshdua1
Hiteshdua1

Reputation: 2286

Make sure that no other application is using port 3000. Try specifying a different port id

This error usually occurs when the port is already in use and your application is trying to run on the same port,

    //SERVER LISTEN
app.listen(3001, ()=>{
  console.log('Server running on port 3001');
});

Upvotes: 3

Related Questions