Connect to sharded cluster?

Currently we use replica sets in Atlas without issue; using the mongodb+srv connection string from the ‘CONNECT’ button on the cluster page we connect nodejs applications, robo3t gui and mongo shell command line with no problems.

We decided to experiment with sharding a cluster in anticipation of increasing volumes of data, so we setup a discreet cluster (non sharded) for test purposes and imported cloned data from one of our running databases. No problem so far.

However once we enabled the “Shard your cluster” option with a value of 2 we can no longer connect to it. Trying to use the “mongodb+srv” value from ‘CONNECT’’ returns a DNS error:
DNSHostNotFound: Failed to look up service

As I understand it we should be connecting to the mongos routers for the sharded cluster. Where are the connection details for the sharded cluster routers to be found in Atlas?

Just a heads up for anyone else who might walk into this.

The DNS error was indeed a problem with the local machine DNS resolution causing the mongodb+srv connection string to fail. Lord alone knows why this particular sharded cluster should have this problem, it is not a problem for the other half a dozen or so atlas databases we connect to. As a work-around we forced DNS to resolve against google’s server and we can get to the database via the srv string.

The second issue was with the database credentials. It uses simple username/password SCRAM mechanism and we had to create a new one to connect to the cluster after we sharded it from being a simple replica set. So it would appear that existing credentials are not applied to the cluster once it has been converted from a replica set.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.