Could not find host matching read preference { mode: "nearest" } for set replicaset1

I am trying to logging in to a shell to a replica set similar to the follwoing.

mongo 'mongodb://user:password@host1:27081,host2:27081,host3:27081/mydb?replicaSet=replicaset1

The error is

{"t":{"$date":"2021-11-01T11:12:10.584Z"},"s":"I",  "c":"NETWORK",  "id":4333208, "ctx":"ReplicaSetMonitor-TaskExecutor","msg":"RSM host selection timeout","attr":{"replicaSet":"replicaset1","error":"FailedToSatisfyReadPreference: Could not find host matching read preference { mode: \"nearest\" } for set replicaset1"}}

I can connect to each individual mongod instance with a shell.

My suspicion is that the mongod instances are inside a Kubernetes cluster and the members of the replica set has different domain names, ports (internal to Kubernetes) from the ones I am trying to connect with.