DB2 Basics: What Port Number is Db2 Listening for Connections on?

DB2 has one or two ports that it is listening on for each and every Db2 instance. Two Db2 instances cannot share a port to listen on. Remember that Db2 allows multiple instances per server and also multiple databases per instance, and has for years.

Determining the Port for a Db2 Instance

The port number used for Db2 connections is configured, and can be changed to meet varying requirements. It is often configured at the time the instance or database is set up or built, and is rarely changed. It must be configured before connections can be made from other servers or client machines. Supported communications protocols are more limited than they once were, but since my early days as a DBA, TCP/IP has become nearly wholly dominant. SSL connectivity over TCP/IP is also allowed. On Windows, Windows named pipes is still a supported protocol.

To find the port number that Db2 is listening on for connections, look at the database manager configuration parameter SVCENAME:

$ db2 get dbm cfg |grep SVCENAME
 TCP/IP Service name                          (SVCENAME) = 50001
 SSL service name                         (SSL_SVCENAME) =

In this case, a number is specified in the configuration. Is it also possible that a name is used, and in that case, we have to map it back to /etc/services.

$ db2 get dbm cfg |grep SVCENAME
 TCP/IP Service name                          (SVCENAME) = DB2c_db2inst1
 SSL service name                         (SSL_SVCENAME) =
$ cat /etc/services |grep DB2c_db2inst1
DB2_db2inst1     50001/tcp

Even if a number is directly specified for SVCENAME, an entry should be added to /etc/services to indicate Db2 is using that port.

When does Db2 Listen on More than One Port for an Instance?

Notice in the output from the DBM configuration that there is another SVCENAME – SSL_SVCENAME. Db2 supports connections using SSL. This is critical to use when database connections are over an unsecured internet connection. This is especially likely (and should be required!)if connecting to Db2 on one cloud or another. When using SSL connectivity, it is possible to only enable SSL connecitons or use both standard connections on SSL connections. If SSL_SVCENAME is set, that indicates that Db2 is likely listening on both ports.

Verifying Db2 is Listening

If you have values for SVCENAME and/or SSL_SVCENAME, you have the DB2COMM registry variable properly set, and you have restarted Db2 after any changes to these variables (without any communications protocol errors on db2start), then Db2 will be listening on these ports. I have never seen Db2 stop listening when it was otherwise functional. There is no concept of independently restarting the listener.

If you want to verify that Db2 is listening on the port you expect it to, you can use netstat to verify this.

$ netstat -an |grep 50001 |grep LISTEN
tcp        0      0 0.0.0.0:50001           0.0.0.0:*               LISTEN

This output indicates that something is indeed listening on this port.

Connecting to Databases from More than One Instance on One Port

If you require using just one port on a server to connect to multiple instances for some reason, you can catalog databases from one or more instances on an instance to allow it to appear that way. If you do this, be sure not to add overhead by cataloging the node as a TCP/IP node, but instead catalog the node as a LOCAL node. You can use this method either with a client instance that has no local databases of its own, or you can simply catalog databases from one instance on another server instance with its own local databases. This same approach could be used to allow connections into a database from multiple ports, but in that scenario, you would have to have a client instance for each port.

Ember Crooks
Ember Crooks

Ember is always curious and thrives on change. She has built internationally recognized expertise in IBM Db2, spent a year working with high-volume MySQL, and is now learning Snowflake. Ember shares both posts about her core skill sets and her journey learning Snowflake.

Ember lives in Denver and work from home

Articles: 544

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.