'ReplicaSet spring-data-mongodb com.mongodb.MongoSocketException: mongo1: nodename nor servname provided, or not known

I'm trying to connect to a replicaSet using remote domain, but it seems like spring-data-mongodb is picking up the internal domain configured for the replicaSet when trying to connect, which of course won't be accessible from my application.

I'm on spring-boot-starter:2.6.2 with spring-data-mongodb:3.3.0 and I'm using spring.data.mongodb.uri to connect to the replicaSet as per the documentation.

This gist should provide enough info to reproduce: https://gist.github.com/Tyngstast/45997c498a25a0ca36026b4669a060c9

Changing the replica set config in the gist to use my machine IP 192.168.x.x as host, instead of docker internal net, works.

Am I missing something, or is this a bug in spring-data-mongodb?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source