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)
Top comments (2)
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.
Being a Linux user,
killall node
works every time!