nodemon: Nodemon - app crashes when restarting due to Node already running on that port
nodemon -v:1.18.6node -v:8.10.0- Operating system/terminal environment:
- Command you ran:
Expected behaviour
Nodemon closes the old Node process and creates a new one
Actual behaviour
Nodemon doesn’t stop the old Node process and then the new one crashes because it’s trying to run on the same port
Steps to reproduce
Run Nodemon and save the file after making changes
If applicable, please append the --dump flag on your command and include the output here ensuring to remove any sensitive/personal details or tokens.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 11
- Comments: 20 (5 by maintainers)
Commits related to this issue
- fix: killing all sub processes Fixes #1463 Fixes #1469 Fixes #1464 — committed to remy/nodemon by remy 6 years ago
- fix: upgrade pstree to remove vulnerability Fixes #1463 Fixes #1469 Fixes #1464 Completely removes the old method of `pstree[.remy]` and drops the event-stream vuln at the same time. — committed to remy/nodemon by remy 6 years ago
My solution:
yarn add kill-portin
nodemon.json:Replace your port:
Change the port to any other port number, just not 3000. for exemple make it 5000 or 4000 it will be okay
with port = 4000
With port = 3000
Just want to follow up. If the ONLY thing I change in my shrinkwrap is the
pstreeversion, which is then used in a docker container and npm runsnpm ci, then with version 1.1.2 it will always fail to reload, with 1.1.0 it will always reload successfully.Looks like 1.1.1 and 1.1.2 were added in quick succession 4 days ago. If I force it to use 1.1.1 nodemon throws this error:
@remy
@arabrain When I tried restarting on different ports I still had the same issue. Right now my fix is to use the following command in the command line:
lsof -ti tcp:5000 | xargs killand then runningnpm run devbut even then sometimes I’ll get the same error.@Aymather u need to kill the process work on the port for exemple 3000 and restart everything.Or u will take my idea, that mean u will change the port every time when u have the same problem.