Can't start mongos process: Address already in use
I'm working with Debian 4.9.168 and I want to configure mongoDB replica set monitoring through google cloud, and I found the best solution is through bindplane bluemedora (currect me if I wrong).
So, I deployed my mongo replica and I need to start a mongos instance. I started it with that command:
sudo mongos --configdb rs0/<MYFIRSTIP>:27019,<MYSECONDIP>:27019 --bind_ip 0.0.0.0and I'm getting that error:
2019-06-09T14:18:07.899+0000 I CONTROL [mongosMain] options: { net: { bindIp: "0.0.0.0" }, sharding: { configDB: "rs0/<MYIP>:27019,35.222.135.175:27019" } }2019-06-09T14:18:07.900+0000 E SHARDING [mongosMain] Failed to set up listener: SocketException: Address already in use 2019-06-09T14:18:07.900+0000 I CONTROL [mongosMain] shutting down with code:48
So I checked if there's a process that uses that address, and there isn't:
netstat -tuna | grep 2701
tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN
tcp 0 0 10.128.0.13:38586 10.128.0.14:27017 ESTABLISHED
tcp 0 0 10.128.0.13:27017 10.128.0.14:56518 ESTABLISHED
tcp 0 0 10.128.0.13:27017 10.128.0.14:56498 ESTABLISHED
tcp 0 0 10.128.0.13:27017 10.128.0.14:56552 ESTABLISHED
tcp 0 0 10.128.0.13:27017 10.128.0.14:56492 ESTABLISHED
tcp 0 0 10.128.0.13:27017 10.128.0.14:56550 ESTABLISHEDmy /etc/mongod.conf file (created automaticly through mongoDB application in Google cloud - ):
# mongod.conf
# for documentation of all options, see:
#
# Where and how to store data.
storage: dbPath: /mnt/mongodb/db journal: enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog: destination: file logAppend: true path: /var/log/mongodb/mongod.log
# network interfaces
#
# MongoDB 3.0.x *debian* packages set bind_ip to 127.0.0.1 by default
# Compute Engine public addresses are properly firewalled by default
# set bind_ip to 0.0.0.0 to emulate pre-2.6 behavior which eases maintenance
net: port: 27017 bindIp: 0.0.0.0
#processManagement:
#security: #authorization: enabled #keyFile: replace_me
#operationProfiling:
replication: replSetName: rs0
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:I really appreciate any kind of help. Thank you :)
1 Answer
You're binding mongos on 0.0.0.0:
--bind_ip 0.0.0.0And by default (from your config), it binds on port 2017:
net: port: 27017 bindIp: 0.0.0.0Your netstat shows that there is already a process listening on 0.0.0.0:2017:
tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN So I suggest either you change your config, or kill your already running mongos process (seems like that is what is using the address). Try checking with the following command:
ps aux | grep mongod 5