October 3, 2022

Robotic Notes

All technology News

Terminate Process on a Port from Command Line

2 min read

Once a week I have to deal with a zombie process or try to start a process that’s already running on its designated port. In most cases I use macOS’s Activity Monitor to kill the process, which is time-consuming. What if we could just kill a process on a given port from the command line? Well, we can!

To terminate a process on a given port, install kill-port and starting nuking those zombies via:

# yarn global add kill-port

# Kill processes on multiple ports
kill-port 6060 8000

If you want to programmatically kill a port that you want to ensure your app will run on, you can do that as well:

const kill = require('kill-port')

kill(6060, 'tcp')
      .then(console.log)
      .catch(console.log)

I look forward to incorporating this library into my Node.js sites so that I can clear the way for a given port and avoid zombie processes.

Website performance monitoring
Website performance monitoring
Website performance monitoring
Website performance monitoring
  • 5 Awesome New Mozilla Technologies You've Never Heard Of

    5 Awesome New Mozilla Technologies You’ve Never Heard Of

    My trip to Mozilla Summit 2013 was incredible. I’ve spent so much time focusing on my project that I had lost sight of all of the great work Mozillians were putting out. MozSummit provided the perfect reminder of how brilliant my colleagues are and how much …

  • fetch API

    fetch API

    One of the worst kept secrets about AJAX on the web is that the underlying API for it, XMLHttpRequest, wasn’t really made for what we’ve been using it for. We’ve done well to create elegant APIs around XHR but we know we can do better. Our effort to …

  • Using Opacity to Show Focus with jQuery

    Using Opacity to Show Focus with jQuery

    A few days back I debuted a sweet article that made use of MooTools JavaScript and opacity to show focus on a specified element. Here’s how to accomplish that feat using jQuery. The jQuery JavaScript There you have it. Opacity is a very simple but effective …

  • Create a Twitter AJAX Button with MooTools, jQuery, or Dojo

    Create a Twitter AJAX Button with MooTools, jQuery, or Dojo

    There’s nothing like a subtle, slick website widget that effectively uses CSS and JavaScript to enhance the user experience. Of course widgets like that take many hours to perfect, but it doesn’t take so long for that effort to be rewarded with above-average user retention and …



Source link