See what process is using a TCP port in Windows Server 2008 - TechRepublic

See what process is using a TCP port in Windows Server 2008

Windows administrators sometimes have to track down network traffic or errant processes and then match that to network traffic. Here are scripts that will aid in the connectivity forensics at the port and process level.

Written By
Rick Vanover
Rick Vanover
Oct 21, 2008
We may earn from vendors via affiliate links or sponsorships. This might affect product placement on our site, but not the content of our reviews. See our Terms of Use for details.

You may find yourself frequently going to network tools to determine traffic patterns from one server to another; Windows Server 2008 (and earlier versions of Windows Server) can allow you to get that information locally on its connections. You can combine the netstat and tasklist commands to determine what process is using a port on the Windows Server.

The following command will show what network traffic is in use at the port level:

Netstat -a -n -o

The -o parameter will display the associated process identifier (PID) using the port. This command will produce an output similar to what is in Figure A.
Figure A

With the PIDs listed in the netstat output, you can follow up with the Windows Task Manager (taskmgr.exe) or run a script with a specific PID that is using a port from the previous step. You can then use the tasklist command with the specific PID that corresponds to a port in question. From the previous example, ports 5800 and 5900 are used by PID 1812, so using the tasklist command will show you the process using the ports. Figure B shows this query.
Figure B

This identifies VNC as the culprit to using the port. While a quick Google search on ports could possibly obtain the same result, this procedure can be extremely helpful when you’re trying to identify a viral process that may be running on the Windows Server.

Stay on top of the latest Windows Server 2003 and Windows Server 2008 tips and tricks with our free Windows Server newsletter, delivered each Wednesday. Automatically sign up today!

Rick Vanover

Rick Vanover is an IT Infrastructure Manager for Alliance Data in Columbus, Ohio. Rick's IT certifications include VMware VCP, Microsoft Windows Server 2008 MCITP, Windows Server 2003 MCSA and others. \ \ Previous experiences included working for Dematic Corp (formerly Siemens L&A, Siemens Dematic, Rapistan)in Grand Rapids, MI in various capacities deploying custom software solutions to the material handling industry using a mix of current hardware and software products. You can reach Rick at b4real@usa.net. Follow rick on Twitter at @RickVanover