question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nodemon leaves old server running when restarting

See original GitHub issue
  • nodemon -v: 2.0.2
  • node -v: v10.15.2
  • Operating system/terminal environment: Windows 10 / VSCode
  • Using Docker? What image: No
  • Command you ran: nodemon

Appeared suddenly. Can run nodemon, save a file once to restart the server, and then the new server seems to fail to handle any requests. When closing this server and attempting to restart it, says the address is already in use.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
eclectic-codingcommented, Apr 28, 2020

I think it is a problem with system speed and the way the process restart on file changes. It seems to happen too quickly and port is still running IMO.

My work around was to set port: const port = process.env.PORT then use the variable in app.listen(port).

In package.json I changed my script: "start": "PORT=3000 nodemon app.js"

This seems to work for now.

3reactions
eclectic-codingcommented, Apr 15, 2020

I can confirm with version 2.0.2 and 2.0.3. I am having the same issues:

events.js:288
      throw er; // Unhandled 'error' event
      ^
Error: listen EADDRINUSE: address already in use :::3000

The project I am working on is at this repo.

For the time being I have included a kill port script in the start script but obviously this is annoying.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nodemon: Error: listen EADDRINUSE: address already in use
From my experience this error, @akkhil seems to be the most correct. I save, restarting the server with nodemon. I sometimes get the...
Read more >
Using nodemon with NodeJS Servers - YouTube
This video explains how you can make your development process more efficient by automatically restarting your web server after ever file ...
Read more >
nodemon events — run tasks at server start, restart, crash, exit
Not very well unfortunately. Because nodemon doesn't run npm start-dev when it restarts the server, the pre command isn't run either. So this...
Read more >
Nodemon Not Killing Node Before Trying To Restart ... - ADocLib
My experience here is that Ctrl+C leaves a node instance running in the when you try to restart 'nodemon server.js' or just 'node...
Read more >
Implementing a secure password reset in Node.js
mongoose to as a driver to interface with MongoDB database; nodemailer to send emails; nodemon to restart the server when a file changes ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found