1

I am relatively new to the MEAN stack. I am facing the following issue. My server is running on port 3000. I am using "nodemon" to handle restarting the server changes. Whenever I include a new dependency by the following command:

npm install "package_name" --save

My server crashes with an error similar to the one given below :

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

Error: listen EADDRINUSE :::3000

Even when I stop "nodemon" and restart "nodemon" it still propagates the same error. This only stops when I go back to the Node.js installer and instead of reinstalling the Node.js application I repair the existing Node.js application. I have a Windows 8.1 OS. After this process, the server works properly and doesn't crash. I am facing this issue for every dependency installation. What could be causing this problem? All the packages/ software used is of the latest version.

Justin Ebby
  • 110
  • 11
  • 1
    duplicate of https://stackoverflow.com/questions/41716833/getting-an-error-listen-eaddrinuse-3000-on-windows-machine – CFrei Jun 28 '17 at 07:52
  • 1
    Ok, so probably on installing these dependencies the server isn't terminating properly and its still retaining hold over the port : 3000. The solution in the link is another way of handling that error ( mine was to repair the Node.js installation in Windows ). But my query is why does the problem occur at all? In a normal scenario, it shouldn't crash at all, and the dependency installation should be seamless. Any way I can fix that (prevent the problem from happening) instead of the handling the error everytime it arises? Thanks! – Justin Ebby Jun 28 '17 at 08:08
  • If you click the link by @CFrei, you'll see you get that error if a process is already running (this usually happens if you closed your terminal while node was running without first closing down the server...)...follow the instructions at the afore mentioned link to manually shut it down...then you shouldn't have that error anymore! – twknab Jun 28 '17 at 09:46
  • Thanks! This helped a lot in finding the root of the problem. – Justin Ebby Oct 27 '17 at 05:58

1 Answers1

1

EADDRINUSE specifies the server or another running process that is listening to the port 3000 in your case .

mostly a previous instance of your app is running , kill it and run it again it should work fine !

Ronak K
  • 1,567
  • 13
  • 23