How do I find out which process is listening on a TCP or UDP port on Windows?

To identify which process is using a specific TCP or UDP port on Windows, follow these steps using built-in tools:

Method 1: Command Prompt/PowerShell (Built-in Tools)

  1. List all ports and their associated PIDs:
   netstat -ano
  • -a: Displays all connections and listening ports.
  • -n: Shows addresses and ports numerically.
  • -o: Includes the Process ID (PID).
  1. Filter for your specific port (e.g., port 80):
   netstat -ano | findstr ":80"
  • Replace 80 with your port number.
  • Look for the PID in the last column.
  1. Find the process name from the PID:
   tasklist /FI "PID eq 1234"
  • Replace 1234 with the PID from the previous step. In PowerShell:
   Get-Process -Id 1234

Method 2: Resource Monitor (GUI)

  1. Press Win + R, type resmon, and hit Enter.
  2. Go to the Network tab.
  3. Under Listening Ports, sort by Port to find your port and its associated process.

Method 3: Sysinternals TCPView (Third-Party Tool)

  1. Download TCPView from Microsoft.
  2. Run Tcpview.exe (no installation required).
  3. Locate your port in the list, which shows:
  • Process name
  • Protocol (TCP/UDP)
  • Local/remote addresses
  • Status

Example Workflow

Check port 8080:

  1. Find the PID:
   netstat -ano | findstr ":8080"

Output:

   TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       1234
  1. Identify the process:
   tasklist /FI "PID eq 1234"

Output:

   Image Name                     PID Session Name        Session#    Mem Usage
   ========================= ======== ================ =========== ============
   node.exe                      1234 Console                    1     250,000 K

Key Notes

  • Run as Administrator: Ensure Command Prompt/PowerShell has elevated privileges to see all processes.
  • UDP Ports: Use the same steps for UDP ports (look for UDP in the Proto column).
  • Persistent Port Issues: Use TCPView to monitor ports in real-time.

Leave a Reply

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