Determine Which Program Uses or Blocks a Port

How to Identify Programs Using or Blocking Ports on Your Computer

Windows:

The Netstat.exe utility has a switch that can display the process identifier (ID) associated with each connection to identify port conflicts. This information can be used to determine which process (program) listens on a given port.

Using Netstat command:

  1. Open a CMD prompt
  2. Type in the command: netstat -ano -p tcp
  3. You'll get an output similar to this one
  4. Look out for the TCP port in the Local Address list and note the corresponding PID number

    Netstat-Command-Prompt-Displaying-TCP-Connections-and-Listening-Ports

Using Task Manager, you can match the process ID listed to a process name (program). This feature enables you to find the specific port that a program currently uses. Because this specific port is already in use by a program, another program is prevented from using that same port.

To Match the Process ID to a Program Using Task Manager:

  1. Press CTRL+ALT+DELETE, and then click Task Manager.
  2. Click the Processes tab.
  3. If you do not have a PID column, click View, click Select Columns, and then click to select the PID (Process Identifier) check box.
  4. Click the column header labeled "PID" to sort the process by their PIDs. You should be able to quickly find the process ID and match it to the program listed in Task Manager. 

To Match the Process ID to a Program Using the Command Line:

Example to find which process uses TCP port 9443:

C:\>netstat -ano -p tcp |find "9443"

Netstat-Command-Filtering-Port-443-Connections-Windows-Command-Prompt

Process with PID 1400 is listening on TCP port 9443. Now, we can query the task list to find the process.

C:\>tasklist |find "1400"

Tasklist-Command-Finding-Process-ID-1400-Windows-Command-Prompt
Here is a typical situation where the EveryonePrint Web service uses TCP port 9443.

Linux:

The Netstat.exe command has a switch that can display the process identifier (PID) associated with each connection to identify port conflicts. This information can be used to determine which process (program) listens on a given port.

Using Netstat command:

  1. Open a terminal
  2. Type in the command: sudo netstat -ano -p tcp
  3. You'll get an output similar to this one
  4. Look out for the TCP port in the Local Address list and note the corresponding PID number

    Netstat-Command-Display-Linux-Server-Listening-Ports-and-Java-Process

To Match the Process ID to a Program:

From the netstat list, you already know the Program name; you can have further details about it using the following command: 

ps -ef | grep <PID number>