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

 

To find out which process is listening on a TCP or UDP port on Windows, you can use the netstat command in the Command Prompt or PowerShell. Here's how to do it with an example:

Using netstat:

  1. Open Command Prompt: Press Win + R, type cmd, and press Enter to open the Command Prompt.

  2. Run netstat: Use the netstat command with the -ano option to display a list of network connections, including the associated process IDs (PIDs).

    To find a specific port (e.g., port 80 for HTTP), you can use the find command to filter the results. Replace 80 with the port number you want to check.

    For TCP:

    bash
netstat -ano | find "80"

For UDP (e.g., port 53 for DNS):

bash
  • netstat -ano -p UDP | find "53"
  • Identify the PID: In the results, you will see a line that corresponds to the port you are interested in. The PID (Process Identifier) column will show the associated process ID.

    Example output for TCP port 80:

    yaml
  • TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 1234

    In this example, 1234 is the PID of the process listening on port 80.

  • Find the Process Name: To find the process name associated with the PID, you can use the Task Manager or the tasklist command.

    • Using Task Manager: Open Task Manager (Ctrl + Shift + Esc), go to the "Details" tab, and look for the process with the matching PID.

    • Using tasklist: In Command Prompt, you can use the tasklist command with the /fi option to filter processes by their PID. Replace 1234 with the PID you found.

      bash
      • tasklist /fi "PID eq 1234"

      This will display information about the process, including its name.

    That's it! You've identified the process listening on the specified port, and you can now determine which application or service it corresponds to.

    Comments