How to find process id name listen TCP/UDP ports in windows

In Windows, Every software or tool has one or multiple process with dependencies.

For example, If you installed apache tomcat on windows, started server, It listens on 8080 port by default.

Some times, if any process runs on same port number, You will get an error 8080 is already in use, Please try different port

This post covers ways to check process id and name details for a given port

nestat command to get process id

netstat command list out all process and type of connection, process id as well as hostname

This command lists following information

  • protocol like TCP or UDP

  • Local address

  • Foreign Address


  • Process ID

    Here is an command to know the process id and protocol type

C:\>netstat -aon

Active Connections

  Proto  Local Address          Foreign Address        State           PID
  TCP                 LISTENING       4
  TCP              LISTENING       3852
  TCP    ESTABLISHED     2268
  TCP    [::]:80                [::]:0                 LISTENING       4 
  UDP           *:*                                    6100

From the above result, you can filter data using pipe symbole with findStr function

C:\>netstat -ano | findStr "3000"
  TCP               LISTENING       16876
  TCP    [::]:3000              [::]:0                 LISTENING       16876

Another way, if you know the process id, you can use tasklist command as seen below

The following find out process id is using which port

C:\>tasklist /fi "pid eq 16876"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
node.exe                     16876 Console                    1     78,472 K

Find out Process name and id using PowerShell in windows

powershell is a powerful command line tool to know process details

The below command finds out process name for given port

PS C:\> Get-Process -Id (Get-NetTCPConnection -LocalPort 3002).OwningProcess

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    281      68   127908      98768      12.64  18548   1 node

below command find out process id for given port number

PS C:\> Get-NetTCPConnection -LocalPort 3002| Format-List

LocalAddress   :
LocalPort      : 3002
RemoteAddress  :
RemotePort     : 0
State          : Listen
AppliedSetting :
OwningProcess  : 18548
CreationTime   : 29-04-2021 12:47:28
OffloadState   : InHost

Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
You'll get a notification every time a post gets published here.