Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to find DB2 port in windows, please help. Some information:

  1. DB2 v 9.7 Personal Edition - new/fresh install
  2. netstat command does not list db2 port.
  3. db2 entry missing was missing in system32\drivers\etc\services file so, made an entry - "db2c_DB2 50000/tcp"
  4. able to start db2 using control center and create tables and insert rows
  5. able to start db2 using CLP and perform opertaions

Actually, I'm trying to connect to DB2 using "jdbc:db2://" as connect URL from Java but, I get an error: "Exception Error opening socket to server / on port 50,000 with message: Connection ref used: connect. ERRORCODE=-4499, SQLSTATE=08001"

I find that DB is up and running but, not listening on port 50000, though mentioned in services file. So, db2 is listening on some other port but,

  1. what's the port it's using?
  2. why it's not using port #50000 as mentioned in services file?
  3. why netstat command is not listing db2 service and port information?

Thanks much in advance.

share|improve this question

migrated from May 29 '11 at 2:50

This question came from our site for professional and enthusiast programmers.

Try tcpview – McDowell May 28 '11 at 18:42
Didn't they switch to port 60000 as of 8.1? Also see:… – Brian Nov 18 '14 at 7:03

Firstly make sure TCP comms is set on,

db2cmd -i -w
db2set DB2COMM=npipe,tcpip

You can check if it's not using the default port,

db2cmd -i -w
db2 get dbm cfg | find "SVCENAME"

Should get a line like this,

TCP/IP Service name                          (SVCENAME) = db2c_DB2

The above would should a port number if it was not set to default port, as you can see my config is default (=50000)

share|improve this answer
I know about "get dbm cfg" but, it does not display port number. It only displays service name... – Sannidhi May 28 '11 at 4:54

You can't do it from Java. You need to find out from the dbadmin or the DB/2 configuration itself. Your item (3) accomplished nothing really: the 'services' file is indicative only, or for use by some clients; it doesn't tell DB/2 what to do. Only DB/2's own configuration does that.

share|improve this answer

First things first, installation displayed an error at the end. I do not remember the error but, I could not start db2. So, googled and found a simple solution and it worked. I could start and perform db operations as can be seen in OP. But, hunt to find port number was still on. After further googling, I found that value for "SVCENAME" was blank, then I updated the parameter and entered port # in services file. Even then, it didn't help. As a last resort, just re-installed DB2 and everything worked fine. Just a note: A successful installation will have value for "SVCENAME" in configuration and db2 will make an entry in services file for service name and port.

share|improve this answer

It seems that when the Service Name DBM parameter is blank, it means that TCP connections are not possible. It is not an problem if you are going to use DB2 locally, by accessing the database from the same machine.

In order to configure TCP connections, you have to follow the steps described in the other answers. However, having an instance without Service Name does not indicate a problem.

There is a discussion about issue in this page:

Because JDBC uses a TCP connection you do really need to change the configuration of your instance in order to connect to the database.

share|improve this answer

Since you are able to start DB2 and connect to a local database from Control Center (via the CLI driver using shared memory), one or more of the following issues may be preventing JDBC connections, which communicate over TCP/IP.

  1. DB2SET must show TCPIP for the DB2COMM setting.
  2. SVCENAME in the DBM config must reflect a valid TCP service name, or preferably, an otherwise unused TCP port number, such as 50000.
  3. Windows firewall must permit inbound connections on the TCP port you've selected for your DB2 instance.

Changes to either the DB2 registry (via DB2SET) or the DBM configuration require DB2 to be stopped and started before they take effect.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.