1

I have configured a three-node replica set in MongoDB. I am able to connect to each server and replication is in sync. But when I'm trying to connect to them as a replica set from a public IP, I am getting an error:

No primary detected for set rs0

But I am able to connect to the replica set from private IPs.

mongo --host rs0/52.X.X.X:27017,52.X.X.X:27017,52.X.X.X:27017 -uroot -pabc123 --authenticationDatabase admin this public IP not able to connect

mongo --host rs0/10.X.X.X:27017,10.X.X.X:27017,10.X.X.X:27017 -uroot -pabc123 --authenticationDatabase admin

With these private IPs we are able to connect to the replica set.

0

Check your firewall settings! If FW is open to outside, you can connect single node even with telnet. Of course check that you haven't configure mongod to listening only private IP network adapter.

If you are behind NATed gateway, there should be redirection from outside network to servers.

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.