How mongo will connect to the primary if the process is exited on the port which I am trying to connect

Hi Guys,

I have scenario where I am running 3 mongo process on port 27000,27001,27002.
When I am connecting mongo on port 27001 and passing replica set name in connection string, I am able to connect Primary.
Let’s say mongo process on 27001 is no longer running and my clients configured with that port only.
So now basically they will not be able to connect.

How can we solve this problem.

Thanks,
GJ

Hi Guptaji_06148,

If mongod process stopped running on port 27001, then the client will not be able to connect using the same port.

However, due to replication, he can connect to other port either 27000 or 27002 and can easily query on data which is same on all 3 nodes.

Kanika

If you use
mongo --host replicaSetName/host1[:porthost1]
and host1 is down, client will not be able to connect to mongodb.

If you use
mongo --host replicaSetName/host1[:porthost1],host2[:porthost1],host3[:porthost3]
client will be able to connect to Primary if there is one.

1 Like