0

I am setting up a replica set of three members in mongodb. All three members of replica set are running mongod instances Active: active (running)

But when i try to check the connectivity using

mongo --host 172.x.x.x --port 27017

by following the instructions given on https://docs.mongodb.com/manual/tutorial/troubleshoot-replica-sets/#replica-set-troubleshooting-check-connection i get,

MongoDB shell version v3.4.4
connecting to: mongodb://172.x.x.x:27017/
2017-05-18T10:11:01.466-0500 W NETWORK  [thread1] Failed to connect to 172.x.x.x:27017, in(checking socket for error after poll), reason: Connection refused
2017-05-18T10:11:01.467-0500 E QUERY    [thread1] Error: couldn't connect to server 172.x.x.x:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:237:13
@(connect):1:6
exception: connect failed

Due to this i am unable to perform rs.add(), i always get the error on server did not responded

Please help!!

Abdul Moiz
  • 1,317
  • 2
  • 17
  • 40

1 Answers1

1

It was the issue with mongo.conf of the host i was trying to connect,

Default Config was:

net:
  port: 27017
  bindIp: 127.0.0.1

I changed it by adding the private IP of my server or you can comment the bindId to accept request from all:

net:
  port: 27017
  bindIp: [127.0.0.1,172.x.x.x]

or

net:
  port: 27017
  #bindIp: 127.0.0.1
Abdul Moiz
  • 1,317
  • 2
  • 17
  • 40