Who is using my port in Windows 7

Table of Contents

I was testing an application that was set to use port 8080. The application failed to start up throwing an exception that the port was in use.

To identify the process tying up port 8080, I opened windows command prompt and typed the following command.

netstat -aop tcp

netstat is useful for displaying active connections and ports on which a computer is listening.

Description of parameters used:

a - Displays all TCP and UDP connections and listening ports

o - Displays the owning process ID associated with each connection

p Protocol - Shows connections for the specified protocol. Protocolc can be TCP, UDP, TCPv6, or UDPv6.

After running the command, I got the following results (truncated):

C:\>netstat -aop tcp 

Active Connections

  Proto  Local Address          Foreign Address        State           PID
  TCP            KagsWin7VB_PC:0        LISTENING       720
  TCP            KagsWin7VB_PC:0        LISTENING       4
  TCP           KagsWin7VB_PC:0        LISTENING       1876
  TCP           KagsWin7VB_PC:0        LISTENING       4
  TCP           KagsWin7VB_PC:0        LISTENING       4


To avoid the hassle of scrolling when the results are many, we can chain the command with findstr using a pipe (|) symbol. This will search for port (8080) which I am interested in from the results of netstat.

netstat –aop tcp | findstr :8080

This will return only connections that contain the string 8080 as seen in the following result.

C:\>netstat -aop tcp | findstr 554
  TCP            KagsWin7VB_PC:0        LISTENING       1876


To forcefully terminate the process using port 8080, I use taskkill command passing the process ID.

taskkill /F /PID 1876