Skip to end of metadata
Go to start of metadata

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.

*** ERROR => NiIBindSocket: SiBind failed for hdl 209/sock 35
            (SI_EPORT_INUSE/98; I4; ST; [nixxi.cpp    3827]

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:


> netstat -nepal|grep 8080
tcp 0 0 :::8080 :::* LISTEN 10404 18906159 7952/java

In this first example (Linux) we see that process with PID 7952 (java) is binding TCP port 8080.


> netstat -nao|findstr 8080
TCP []:8080 []:0 LISTENING 3696

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.


> netstat -Aan | grep 8000 | grep LISTEN
f1000e000130bbb8 tcp4       0      0  *.8000                *.*                   LISTEN
> rmsock f1000e000130bbb8 tcpcb
The socket 0xf1000e000130b808 is being held by proccess 13893704 (icman).
> ps -ef | grep 13893704
  vmcadm 13893704  9175156   0   Dec 22      -  0:17 icman -attach pf=/usr/sap/VMC/SYS/profile/VMC_DVEBMGS00_is4039



> ps -ef| awk '{print $2}'| xargs -I '{}' sh -c 'echo Verifying PID {}; pfiles {} 2>/dev/null|grep "port: 3900"|grep -v grep'
Verifying PID 3150
Verifying PID 4848
Verifying PID 4891
Verifying PID 7900
   sockname: AF_INET  port: 3900
Verifying PID 4831
Verifying PID 23568
Verifying PID 7928
Verifying PID 9662
> ps -ef|grep 7900|grep -v grep
  qpkadm  7900  7840   0   Jun 21 ?           1:38 ms.sapQPK_DVEBMGS00 pf=/usr/sap/QPK/SYS/profile/QPK_DVEBMGS00_fs4400

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.



<back to FAQ section>