Unable to connect using replicas uri (docker setup)

Hi @chris,

Thank you for your response.

I have no issue connecting to the database via mongo3t to the primary set

image

But when I tried to connect to my primary and secondary, it can’t.

both mongodb://mongo-primary:30000,mongo-secondary:30001/test?replicaSet=rs0 and mongodb://mongo-primary:30000,mongo-secondary:30001,mongo-arbiter:30002/test?replicaSet=rs0 won’t connect

image

I have no problem pinging to each individually, I have added those to my host system hosts file

image

image

image


When connecting to a replica set the client has to be able to connect to each node as defined in the replica set configuration .

When connecting to a replicaSet the hosts listed (explicit or implicit mongodb+srv) are the seed hosts for the client. The client will then discover the hosts in the cluster from that seed node.

I’m not exactly sure what you meant here.


Programmatically, I am able to connect via mongodb://mongo-primary:30000/test through mongoose as well but am not able to when I change to mongodb://mongo-primary:30000,mongo-secondary:30001,mongo-arbiter:30002/test?replicaSet=rs0. My goal here is to be able to connect via mongodb://mongo-primary:30000,mongo-secondary:30001,mongo-arbiter:30002/test?replicaSet=rs0

I’m not exactly sure which step I did wrongly, please guide me along. Appreciate it.

Thank you