0

I decided to change the structure of my routes to organize them a little better in my project. I'm now using a folder structure for user/admin roles.

Whenever I save a file, the usual behavior was that nodemon will restart my server and if nothing was wrong, it will start the server and connect to the DB (MongoDB). However, since I changed this, whenever I do save a new file or create it, I get an error saying listen EADDRINUSE: address already in use :::5000.

There's nothing really wrong with the code, as once I save again it does both with no problem.

Error example taken from the terminal

Any idea of what might be going on?

devjavi
  • 25
  • 6
  • it's supposed to stop the server and restart, but apparently it fails to stop it, hence reuse the port 5000. try to exit and rerun nodemon. – emrhzc May 02 '20 at 20:13
  • Have a look [at this question](https://stackoverflow.com/questions/4075287/node-express-eaddrinuse-address-already-in-use-kill-server) – reymon359 May 02 '20 at 20:15
  • I actually didn't notice I had another instance of nodemon running in the background on another terminal. So it was actually trying to connect both instances at the same time and that's why it failed sometimes. Closing that one solved it. – devjavi May 02 '20 at 20:27
  • @devjavi please post that as an answer, not an edit to your question – Sathyajith Bhat May 02 '20 at 20:28
  • @SathyajithBhat thanks for the suggestion, rookie mistake for me. – devjavi May 02 '20 at 20:48

1 Answers1

1

I actually had another terminal running in the background so I had two instances of nodemon doing the same. Closing that fixed it


devjavi
  • 25
  • 6