Commands / Network

Get-NetTCPConnection

Find which program is using a port

intermediate Network

Get-NetTCPConnection
 Get-NetTCPConnection -LocalPort 8080 | Select-Object LocalAddress, LocalPort, State, OwningProcess
Works on
Windows
PowerShell
5.1 and later
Reference
Microsoft Learn: Get-NetTCPConnection

"Port 8080 is already in use" usually means another program got there first. This shows which one.

OwningProcess is a process ID. Pass it to Get-Process to get the name.

Try this

Name the program on a port:

$conn = Get-NetTCPConnection -LocalPort 8080 -ErrorAction SilentlyContinue | Select-Object -First 1
if ($conn) { Get-Process -Id $conn.OwningProcess } else { 'Nothing is using port 8080.' }

Everything that is listening for connections:

Get-NetTCPConnection -State Listen |
    Sort-Object LocalPort |
    Select-Object LocalPort, @{ Name = 'Process'; Expression = { (Get-Process -Id $_.OwningProcess).ProcessName } }

Coming from another shell

ShellWhat you might type
bash / zshsudo lsof -i :8080
cmd.exenetstat -ano | findstr :8080

More in From bash and From cmd.

Related commands