<p>I am using stable-mongodb-replicaset  helm chart for creating mongodb inside my k8s cluster hosted on Azure. mongodb has three replicas.stable-mongodb-replicaset acts as an sub chart.</p>

<p><br>
my release name is skeleton.
i can see my mongodb replicaset is up and running. i tried connection  for it and it also works fine. as per documentation i tried connecting to this replicaset with service client but it throws error.</p>

<p><strong>URL i am using for connection is</strong> </p>

<pre><code>"mongodb://myuser:mydbpwd@skeleton-mongodb-replicaset-client:27001/skeleton?authSource=admin&amp;replicaSet=rs0"
</code></pre>

<p>output of mongodb service</p>

<p><a href="https://i.stack.imgur.com/a86mg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a86mg.png" alt="enter image description here"></a></p>

<pre><code>[1;30m2019-04-28 14:34:34,483 [0;39m =&gt; [34mINFO [0;39m [ [32mlocalhost-startStop-1 [0;39m] [33mcom.mongodb.diagnostics.logging.SLF4JLogger [0;39m: Cluster created with settings {hosts=[skeleton-mongodb-replicaset-client:27001], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[1;30m2019-04-28 14:34:34,485 [0;39m =&gt; [34mINFO [0;39m [ [32mlocalhost-startStop-1 [0;39m] [33mcom.mongodb.diagnostics.logging.SLF4JLogger [0;39m: Adding discovered server skeleton-mongodb-replicaset-client:27001 to client view of cluster
[1;30m2019-04-28 14:34:34,984 [0;39m =&gt; [34mINFO [0;39m [ [32mcluster-ClusterId{value='5cc5b9fab13658000122961a', description='null'}-skeleton-mongodb-replicaset-client:27001 [0;39m] [33mcom.mongodb.diagnostics.logging.SLF4JLogger [0;39m: Exception in monitor thread while connecting to server skeleton-mongodb-replicaset-client:27001
com.mongodb.MongoSocketOpenException: Exception opening socket
        at com.mongodb.connection.netty.NettyStream$2.operationComplete(NettyStream.java:158)
        at com.mongodb.connection.netty.NettyStream$2.operationComplete(NettyStream.java:145)
        at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:511)
        at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:504)
        at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:483)
</code></pre>

<p>we are using driver org.mongodb:mongodb-driver-async 3.6.4 version while mongodb version we are using is 4.0 </p>

Ganesh Pol
<p>The headless service is used to control the network domain.  <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">As each pod is created, it gets a matching DNS subdomain, taking the form: $(podname).$(governing service domain)</a>
Therefore to connect to the replicaset I believe you need to use: 
"mongodb://myuser:mydbpwd@<strong>skeleton-mongodb-replicaset-0</strong>.skeleton-mongodb-replicaset:27001,<strong>skeleton-mongodb-replicaset-1</strong>.skeleton-mongodb-replicaset:27001,<strong>skeleton-mongodb-replicaset-2</strong>.skeleton-mongodb-replicaset:27001/?authSource=admin&amp;replicaSet=rs0"</p>

<p>And to second @yanivoliver's question - why non-standard port?</p>
