DEV Community

Cover image for Kill an anoying "invisible" process running in localhost πŸ”«πŸ˜’
Marcos Henrique
Marcos Henrique

Posted on

Kill an anoying "invisible" process running in localhost πŸ”«πŸ˜’

I was working on a project in Vue running with yarn dev (dev-server), but gone out for a coffee β˜• when I returned to table my nootebook was bugged πŸ˜’, like every windows user, I did the magic shortcut πŸŽ‡ (crtl + alt + del) for the task manager and I restarted the crashed process (my hyper bash, if you don't know hyper see more here which was running my application, in my innocence I thought I could run yarn dev again

But it throw an error looks like that A process is already running on port 3000, finish it to run on this port I did the magic shortcut πŸ˜ͺ, and for my surprise, nothing running in task manager...

How I solve this anoying error? πŸ€”

Run command-line as an Administrator

netstat -ano | findstr :portnumber
Enter fullscreen mode Exit fullscreen mode

Now you will see something like that:

Pink coloured rectangle area shows the PID (process identifier)

Let's kill it 😎

Then you execute this command after identify the PID.

taskkill /PID yourPID /F
Enter fullscreen mode Exit fullscreen mode


(The /F option forcefully terminates the process)

Run the first command again to check if process is still available or not.
You'll get empty line if process is successfully ended.

The superb way 🀺

Run Windows PowerShell to stop a process on your wanted port, just type:

Stop-Process (,(netstat -ano | findstr :yourPort).split() | foreach {$[$.length-1]}) -Force
Enter fullscreen mode Exit fullscreen mode

OK, this saved my skin, but WTF is nestat?

Netstat β€” derived from the words network and statistics β€” is a program that’s controlled via commands issued in the command line. It delivers basic statistics on all network activities and informs users on which portsand addresses the corresponding connections (TCP, UDP) are running and which ports are open for tasks (if want know how this properly works, you can read more here)

Hope this helps if you come across this boring error πŸ€—

That's all, folks

Top comments (2)

Collapse
 
lilotop profile image
Lilo

Since you're working on vue projects, you might also want to try the vue CLI ui (run vue ui in your console).
The vue ui has a "kill port" utility that does just that.

Collapse
 
anduser96 profile image
Andrei Gatej

Being a Linux user, killall node works every time!