Port usage warning (SQL5043N)

When an instance is started (using the db2start command), listeners are also started to accept the connect request from clients. However, there are instances where the listeners may fail to start because the port that they are listening to may be used by a different application, which throws a SQL5043N warning.

Cause

When the db2start command gives the following warning, SQL5043N, "Support for one or more communications protocols failed to start successfully. However, core database manager functionality started successfully." The following message is an example of what would be logged in the db2diag.log file:
2007-01-23-22.45.33.315991-300 LEVEL: Error
PID     : 3268824     TID  : 1       PROC : db2sysc 0
INSTANCE: db2inst1    NODE : 000
FUNCTION: DB2 UDB, common communication, sqlcctcpconnmgr, probe:46
MESSAGE : ADM7007E  The SVCENAME DBM configuration parameter, "50000", is configured with a port or a service name.  
When it is configured with a service name, the TCP/IP services files is used to map the service name to a port number.  
The port specified in this field is being used by another process.  
Resolve this problem by either deleting the process using the port or use another port.

The example db2diag.log file shows that the TCP/IP listener (db2tcpcm) failed to start because the required port, port 50000 in this example, was already being used by another application. The simple resolution is to use a different port for the listener. If you have to use that specific port, you should terminate the application that's using it.

Answer

In the following AIX®, Windows and Linux® examples, you can use the commands for each operating system below to determine which application or process is using the port.
Note: The SQL5043N warning can be returned for various reasons. This only applies to the case where the port is used by another application.

AIX

  1. Run the following command:
    lsof -i :<port number>

    This command must be run as root.

AIX example

Let's set SVCENAME to 50000, so that the listener will use this port:
$ db2 update dbm cfg using svcename 50000
$ db2start
Then, use the command mentioned earlier to check if the port is indeed being used by Db2®. Run this as root.
$ lsof -i :50000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
db2sysc 4128774 db2inst1 5u IPv6 0xf1000e00019f3bb8 0t0 TCP *:50000 (LISTEN)

Windows

  1. Run the following command:
    netstat -aon | findstr "<port number>"

    Running this command shows if the specified <port number> is being used. The number in the last column is the process id (PID) of the process holding the socket. Once PID is determined, you can refer to the "Windows Task Manager" to determine which application corresponds to the PID.

Windows example

C:\>netstat -aon | findstr "50000"
TCP    0.0.0.0:50000     0.0.0.0:0       LISTENING       2564

C:\>pslist 2564

pslist v1.28 - Sysinternals PsList
Copyright ⌐ 2000-2004
Sysinternals

Process information for MACHINENAME:
Process information for MACHINENAME:

   Name      Pid Pri Thd  Hnd   Priv     CPU Time  Elapsed Time
   db2syscs 2564   8  15  366  30912  0:00:02.859   2:12:08.564
The previous example shows the use of pslist to determine the name of the process.
Note: pslist is a free command available from Microsoft Sysinternals. You can find it here.

Linux

  1. Run the following command:
    netstat -anp | grep <port number>

    This command shows the PID and the program name that uses that port. The command must be run as root.

  2. Alternatively, you can also run the following command instead:
    fuser -n tcp <port number>

Linux example

In this example, port 12345 is being used by someone else. Run the following commands to find out who is using the port.
# netstat -anp | grep 12345
# netstat -anp | grep 12345
tcp    0   0 127.0.0.1:12345   0.0.0.0:*    LISTEN   6629/ssh
tcp    0   0 ::1:12345              :::*    LISTEN   6629/ssh
ssh with the PID 6629 is using the port. Find more info about it.
# ps -efl | grep 6629
4 S root      6629 29716  0  75   0 -  6976 -      14:05 pts/4    00:00:00 ssh testserver -D 12345 -l db2inst1
0 S root      7648  7302  0  78   0 -   742 pipe_w 14:07 pts/7    00:00:00 grep 6629

In this case, the user db2inst1 is deliberately using port 12345 by specifying -D option of ssh.