Cannot connect to Mongodb replicaset

I Use rancher to create an cluster with Amazon EKS.

Deployed a nodejs app in ‘default’ namespace.

Installed MongoDB replicaset from the rancher app catalog with default settings.

  • Service/Deployment name is mongodb-replicaset
  • namespace is also mongodb-replicaset

When I use
mongodb://mongodb-replicaset:27017/tradeit_system?replicaSet=rs as connection string.

I get the error.

MongoNetworkError: failed to connect to server [mongodb-replicaset-:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND mongodb-replicaset mongodb-replicaset:27017]

Then I read in kubernetes documentation that to access a service in a different namespace you need to also specify the namespace along with the service name.

So I did this


MongoError: no primary found in replicaset or invalid replica set name

Got same error with this as well.


Hello, I’m trying to deploy MongoDB replica set on Rancher 2.0 using catalog as well. I don’t know how to connect to my replica set, did you solved your problem?


This connection string worked for me: