How to check open TCP/IP ports in Windows
As a developer, I tend to write server applications that expose services through TCP/IP ports. This is a common practice when developing applications that use the client-server architecture (web applications, web services, and so on). Commonly, you might sometimes run into conflicts with other applications or services running on the same machine that use the same port. The following is a quick guide on how to check if a TCP/IP port is open in Windows.
Using the netstat command
The netstat command is a built-in command line tool that provides statistics for TCP/IP and UDP protocols. It is available on all modern Windows operating systems.
The following command will list all open ports in numerical order including the Process ID (PID) that has opened the port:
netstat -anb
The next screenshot shows the output of the command above running on my Windows XP machine:
As you can see in the screenshot, the output is showing that port 80
is being used by the hfs.exe
process with PID 1368
.
The parameters used in the command are:
-a
- Displays all active TCP connections and the TCP and UDP ports on which the computer is listening.-n
- Displays active TCP connections, however, addresses and port numbers are expressed numerically and no attempt is made to determine names.-b
- Displays the executable involved in creating each connection or listening port.
You can read more about these options at learn.microsoft.com.