How to determine which ports are in use in Windows

  • 7019231
  • 18-Dec-2015
  • 07-Aug-2017

Environment


Retain
Windows

Situation


Something is preventing Retain from starting up properly or running a job properly.

Resolution


Retain needs access to a large number of ports and occasionally there are port conflicts. In Windows it can be challending to determine what process is using which port.

Telnet

To determine if a port is in use you can telnet from a workstation to the server by provding the host address (a telnet client can be activated from Programs and Features):

telnet host port

It will return something along these lines:

  • connection refused = the port is unused
  • accepted = the port is in use
  • timeout = the port is blocked by the firewall

Netstat

A command line tool you can use is netstat and it provides a way to find the program using a port.

netstat -noa

This will return a long list of connections. For example:

Active Connections

  Proto  Local Address          Foreign Address        State           PID
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       556
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:8081           0.0.0.0:0              LISTENING       1248

The High Performance Indexer uses port 8081. We can use tasklist and findstr to see what is using that port by using the PID listen on the same line:

tasklist | findstr 1248

and that returns:

tomcat7.exe                   1248 Services                   0  2,004,520 K

Tomcat is used by Retain so this is the output we expect if it is something else (e.g. frameworkservice.exe) then we know something (e.g. McAfee) has already seized the port and Retain is unable to load. You will have to decide which program's ports need to change and document that.

see also: Ports Used by Retain

Additional Information

This article was originally published in the GWAVA knowledgebase as article ID 2686.