Home > front end >  How to find port on windows (using pid or processes name)
How to find port on windows (using pid or processes name)

Time:01-21

How to find port on windows (using pid or processes name)

I know the PID, but I need the port on which the processes are running

CodePudding user response:

you can use the following CMD command (Open it as administrator)

 netstat -aon | findstr PID

There more different ways to find process port available here.

CodePudding user response:

The accepted answer to the question that Nikita's answer links to - https://stackoverflow.com/a/48199/45375 - can be adapted to your needs with the following PowerShell command (assumes that the PID of interest is stored in $yourPid):

(Get-NetTCPConnection | Where-Object OwningProcess -eq $yourPid).LocalPort |
  Select-Object -Unique

Note that even weeding out duplicates can result in multiple ports getting returned.

See also:

  • Related