Bartula Code

Check which process using socket

If you want to check which porcess accessing to the some url/port
Use this:

netstat -a -n -o | findstr "8080"

Replace 8080 with port which you are looking for. In the last column it will print proces PID application which using socket.

For example:

  • 80 - HTTP,
  • 8080 - (Development HTTP)
  • 443 - HTTPS,
  • 8443 - (Development HTTPS)
  • etc ssh, or your custom application port

Usage example for 443

  TCP    [2a02:...:575f]:62386  [2620:...::200]:443  ESTABLISHED     9396
  TCP    [2a02:...:575f]:62387  [2620:...::200]:443  ESTABLISHED     9396
  TCP    [2a02:...:575f]:62388  [2620:...::200]:443  ESTABLISHED     9396

If you would like get the application name, use script below.

netstat -aon | Select-String 8080 | ForEach-Object { $_ -replace '\s+', ',' } | ConvertFrom-Csv -Header @('Empty', 'Protocol', 'AddressLocal', 'AddressForeign', 'State', 'PID') | ForEach-Object { $portProcess = Get-Process | Where-Object Id -eq $_.PID; $_ | Add-Member -NotePropertyName 'ProcessName' -NotePropertyValue $portProcess.ProcessName; Write-Output $_ } | Sort-Object ProcessName, State, Protocol, AddressLocal, AddressForeign | Select-Object  ProcessName, State, Protocol, AddressLocal, AddressForeign | Format-Table

Source

Replace 8080 with port of application which is looking process using. It will display process names wich are using it. Example output with 443:

Spotify     ESTABLISHED TCP      [2a02:...:575f]:62375 [2a04:...:8d::760]:443
Spotify     ESTABLISHED TCP      [2a02:...:575f]:62376 [2a04:...:8d::760]:443
Spotify     ESTABLISHED TCP      [2a02:...:575f]:62485 [2600:...:1:c36::]:443

Read more

HTTP 204 - No Content