Common Issue : MongoDB Expanding Hyphens in URL’s with Cluster URL’s
We have seen customers trip up over a very subtle problem with the expansion from the mongodb+srv URL to the cluster URLs.
If your mongodb+srv URL is
yourhost-abcd123.mongodb.net with hyphen (-) between yourhost and abcd123. That
means when you do the URL expansion for the tunnels, you need to use the hyphen as well.
So that would mean your tunnels need to be setup as:
yourhost-shard-00-01-abcd123.mongodb.net:27017 yourhost-shard-00-00-abcd123.mongodb.net:27017 yourhost-shard-00-02-abcd123.mongodb.net:27017
Note the hyphens instead of the periods before abcd123.
The same is true if you use a “.” in the mongodb+srv URL, for example
yourhost-shard-00-01.abcd123.mongodb.net:27017 yourhost-shard-00-00.abcd123.mongodb.net:27017 yourhost-shard-00-02.abcd123.mongodb.net:27017
Hopefully this helps avoid this slight pitfall and gets you up and running.