How to find the process binding a TCP port?
We have several error scenarios on which some SAP process cannot start because some other process has already bound its TCP port.
This error message that can be seen in most of the component trace files, tells us that port 8000 is already being used (bound) by another process. To find out which process is using this port, the "netstat" tool can be used. Netstat is a command-line tool that displays network connections (both incoming and outgoing), routing tables, and a number of network interface statistics. Follows the procedure example on both UNIX and WINDOWS platforms:
In this first example (Linux) we see that process with PID 7952 (java) is binding TCP port 8080.
In the Windows example, we find out that process with PID 3696 is the one binding the relevant port (8080).
It is also possible to use "netstat -ab" in Windows where it will list the process responsible to bind the port. The option "a" list all connections and the option "b" display the executable involved.
The first command will print a list with the PID of all processes that are active at the system. The port number must be adjusted at the first "grep" command.
The PID that is using the port will be the one immediately before the line that ends with "port: <port>" ("port: 3900" in the example above).
The second command will show information about the process itself.
With this information, it can be decided whether this process should use this port or whether it can be stopped or reconfigured to use another port.