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

and I'm getting that error:

2019-06-09T14:18:07.899+0000 I CONTROL  [mongosMain] options: { net: { bindIp: "" }, sharding: { configDB: "rs0/<MYIP>: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 *               LISTEN     
tcp        0      0       ESTABLISHED
tcp        0      0       ESTABLISHED
tcp        0      0       ESTABLISHED
tcp        0      0       ESTABLISHED
tcp        0      0       ESTABLISHED
tcp        0      0       ESTABLISHED

my /etc/mongod.conf file (created automaticly through mongoDB application in Google cloud - https://console.cloud.google.com/marketplace/details/click-to-deploy-images/mongodb):

    # mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
  dbPath: /mnt/mongodb/db
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
# MongoDB 3.0.x *debian* packages set bind_ip to by default
# Compute Engine public addresses are properly firewalled by default
# set bind_ip to to emulate pre-2.6 behavior which eases maintenance
  port: 27017


  #authorization: enabled
  #keyFile: replace_me


  replSetName: rs0


## Enterprise-Only Options:



I really appreciate any kind of help. Thank you :)


You're binding mongos on


And by default (from your config), it binds on port 2017:

  port: 27017

Your netstat shows that there is already a process listening on

tcp        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
  • mongos is not running :( ps aux | grep mongos idan_ch+ 2228 0.0 0.0 12780 1004 pts/0 S+ 15:01 0:00 grep mongos – Idan Chau Jun 9 at 15:01
  • @IdanChau try using netstat -tunap (add the -p flag for process ID and name) – Fanatique Jun 10 at 8:08
  • still there isn't mongos process. my netstat -tunap output – Idan Chau Jun 10 at 8:34
  • @IdanChau what do you mean there isn't? There is. The process name is mongod. The first process which is listening on is mongod. I'll edit my answer, run ps aux | grep mongod and then check. – Fanatique Jun 10 at 9:27
  • yeah mongod is running, but I'm trying to start mongos too. When I killed mongod and started mongos I got error of "can't connect to master" so I needed to start both processes, but when I try to start mongos AND mongod (but in another port) it says address already in use - no matter which port I use. – Idan Chau Jun 10 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.