-2

Hey guys I know this is a question that has been tackled few times with different flavors. I was just curious if any of you knew the magical hot-key in Ubuntu to kill a node process without facing the infamous EADDRINUSE ::XXXX issue when you restart your process. I know already there are many ways of finding the pid of the process using the port and properly killing it;

sudo ss -lptn 'sport = :XXXX'

kill -9 PID

But there must be a nicer way.

In the hope of some Linux guru may help.

Thanks

Mark Odey
  • 170
  • 2
  • 12
  • Just create a script for the commands and run that instead – Alexis Pavlidis Nov 22 '19 at 17:07
  • I realize that my question is unpopular. I am specificaly asking for a hot-key to stop process and ensure that process using the port are totally free. Why aren't process properly cleared anyways? – Mark Odey Nov 25 '19 at 15:15

2 Answers2

0

Maybe you could use this: kill $(lsof -t -i:portnumber) if you know what port the process runs on.

I found this in this answer: How to kill a process running on particular port in Linux? and tested it.

Laurent Dhont
  • 1,012
  • 1
  • 9
  • 22
  • Yes that works but would there be a way to cleanly free the used ports once stopping node with ctrl+x or ctrl+z or ctrl+c? – Mark Odey Nov 25 '19 at 15:18
-1

After all, if anybody face this newbie error like I had, in linux ubuntu the golden rule is that usually ctrl+c shuts down process properly and frees the used port of the process.

ctrl+c

Sorry for the bad question.

Mark Odey
  • 170
  • 2
  • 12