Find out the name of a process using a port and stop it if necessary.

Oct 9, 2020 | Scripting and programming, Server administration, Windows | 0 comments

Just a quick one.
Here are a few useful commands to have in your toolbox to find the process bound to a port in Windows. Then stop it.
I’ve provided commands for both command prompt and PowerShell. The PowerShell way is much nicer in my opinion.

In command prompt:

# Get the process ID (PID) of processes listening on port 443.
netstat -a -n -o | find "443"

# Get the process name from a pid.
tasklist /fi "pid eq 1234"

#Kill a task with a given PID:
taskkill /pid 12344

Now in PowerShell:

#PowerShell get the process details listening on a given port:
Get-Process -Id (Get-NetTCPConnection -LocalPort 443).OwningProcess

# Stops the process that you found listening on the port with get-process.
stop-process -confirm (Get-Process -Id (Get-NetTCPConnection -LocalPort 443).OwningProcess)


Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.