Showing posts with label TCP/IP. Show all posts
Showing posts with label TCP/IP. Show all posts

Thursday, August 4, 2016

How to find the database connection strings?

To find the database connection strings such as url, port number etc:

Database URL can be found using the command ifconfig -a.

en1: flags=xxxxx,480
        inet xxx.xxx.xx.xx netmask 0xffffff00 broadcast xxx.xxx.xx.xx
         tcp_sendspace 12345 tcp_recvspace 12345 rfc1323 1
en2: flags=xxxxx,480
        inet xxx.xxx.xx.xx netmask 0xffffff00 broadcast xxx.xxx.xx.xx
         tcp_sendspace 12345 tcp_recvspace 12345 rfc1323 1
lo0: flags=xxxxx,c0
        inet xxx.xxx.xx.xx netmask 0xff000000 broadcast xxx.xxx.xx.xx
         tcp_sendspace 12345 tcp_recvspace 12345 rfc1323 1


Port number can be found using these steps:

  • db2 get dbm cfg|grep -i svcename
    •  TCP/IP Service name                          (SVCENAME) = db2_db2inst1

  • Search for the svcename value in /etc/services file (cat /etc/services|grep -i db2_db2inst1)
    • db2_db2inst1   50000/tcp 

  • Check if the port is listening
    • netstat -Aan|grep -i 50000

Wednesday, May 11, 2016

DB2 LUW - Connection refused. ERRORCODE=-4499, SQLSTATE=08001

Application developer says that he is not able to connect to the database, he's getting a message similar to this:
"Error opening socket to server /nnn.nnn.nnn.nnn on port 50,000 with message: Connection refused. ERRORCODE=-4499, SQLSTATE=08001"

How do you resolve it?


  • Get the TCP/IP service name: 
    • Issue this command: db2 get dbm cfg|grep -i svce
    • The output will be something like this:
    • TCP/IP Service name                          (SVCENAME) = svce_db2inst1
    •  
  • Verify the port number:
    • Issue this command: cat /etc/services|grep -i svce_db2inst1
    • The output will be something like this: svce_db2inst1   50000/tcp
    •  
  • Make sure the port is listening:
    • Issue this command: netstat -Aan|grep -i 50000
    • If you do not see any output, it means the port is not listening and that's a problem
  • If the port is not listening, check the db2set parameter:
    • Issue this command:  db2set
    • If you don't see a DB2COMM parameter, then it needs to be set for applications to communicate with DB2
    • Update the DB2COMM parameter with this command: db2set db2comm=TCPIP
    • Stop and restart the DB2 instance: db2stop and db2start 
  • After restarting DB2, check if the port is listening by issuing the command "netstat -Aan|grep -i 50000". If the port is listening, you'll see the output similar to this:
    • f1000e00057aebb8 tcp4       0      0  *.50000               *.*                   LISTEN
    • f1000e00054ddbb8 tcp4       0      0  nnn.nnn.nnn.nnn.50000   nnn.nnn.nnn.mmm 33xxx   ESTABLISHED
    • f1000e000b3653b8 tcp4       0      0  nnn.nnn.nnn.nnn.50000   nnn.nnn.nnn.mmm 33yyy   ESTABLISHED
HTH !!