Skip to content

Instantly share code, notes, and snippets.

@restyler
Last active May 29, 2023 07:10
Show Gist options
  • Save restyler/c3c4371f9bfb83302a3333d92762cd32 to your computer and use it in GitHub Desktop.
Save restyler/c3c4371f9bfb83302a3333d92762cd32 to your computer and use it in GitHub Desktop.
Kill detached nodemon node.js process by node process port

When my VS code remote disconnects and looses my nodemon terminal after window reload, I always spend 3-4 minutes googling how to quickly kill the nodemonized process.

  1. Get pid by port (2355 in my case):

sudo lsof -n -i :2355

if you kill the found PID it won't help since nodemon will restart it. So, get PID from output (63073 in my case and..

  1. Now find the parent of this process (nodemon):

ps -o ppid= -p 63073

  1. Make sure this is the correct PID of nodemon (50461 was the output of the previous command):

ps aux | grep 50461

  1. Kill nodemon kill 50461
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment