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

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

wakeupmh profile image Marcos Henrique ・2 min read

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

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


(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

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

Discussion

pic
Editor guide
Collapse
anduser96 profile image
Andrei Gatej

Being a Linux user, killall node works every time!

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.