Sometimes a mistake made by db administrator causes that kind of problem.
To solve this problem we need to take a few simple steps and check system services.
First of all, you need to get database service configuration with this command:
db2 get dbm cfg | grep SVCE
Does that value empty? You need to set a port number to test (we will change it with service name)
Now you should find an empty port, for example 55000. Let’s find if it is in use:
netstat -an | grep LISTEN | grep 55000
That command must return an empty result set. If it returns a row, you need to choose a different port.
Stop db2 and update your configuration for port 55000
db2stop db2 update dbm cfg using SVCENAME 55000
Now start db2 and check does db2 listening port 55000.
db2start netstat -an | grep 55000
You MUST see port 55000 is actively listening. If you can confirm that, db2 is listening 55000, jump to Modifying /etc/services section.
If port 55000 still is not in the list you need to update db2 system variables via that simple commands.
db2stop db2set DB2COMM=TCPIP db2start db2set -all
Last command lists db2 system variables. DB2COMM must be set to TCPIP to listen TCP ports.
Modifying /etc/services
Most of *nix system users are familiar with /etc/services file. In *nix systems, service names and their port and protocol are stored in this file.
We have a simple template to add db2 service to end of this file.
db2c_<instance_name> <port_number>/tcp #db2 service port
Open that file via vi (or your favorite text editor) and add your db2c_…. row to end of /etc/services.
And now, you must update db2 configuration with your new service name:
db2stop db2 update dbm cfg using SVCENAME db2c_<instance_name> db2start
Do not forget to change <instance_name> with your db2 instance name.
Confirm that db2 is listening port in /etc/services.