If you have heaps of things running locally in docker containers, node mocks and other development realted things you may run into port clashes. Often after I close a console running a node mock it still hangs around -_-
I use netstat which should be installed with Windows to identify used ports and then kill the process.
Port Known
When the process is running on port 53 you can filter in powershell by piping the response into Select-String. You could the pipe this into taskkill but that doesnt feel smart and Id rather do it manually.
1 | netstat -ano | Select-String "53" |
Note that the above would also match on any PID matching 53.
Search Port Unknown
1 | netstat -a -n -o |
What do those switches mean?
-adisplays all connections, including those that are listening for incoming connections.-ndisplays the IP addresses and port numbers in numerical form, rather than trying to resolve them to hostnames.-odisplays the process ID (PID) of the process that created each connection.
Example response
1 | Active Connections |
Kill process by PID
Take the PID from the responses above and pass it below.
1 | taskkill /PID 7860 /F |