com.mongodb.MongoConfigurationException: Failed looking up TXT record for host xcluster.nuncuef.mongodb.net

I have mongoDb atlas instance running, but when trying to connect it throws this error com.mongodb.MongoConfigurationException: Failed looking up TXT record for host xcluster.nuncuef.mongodb.net. Connection is successful on windows machine, but not on the osX one. Using Intelijj with ktor and kmongo. Also, I can connect through mongo shell. Does anyone know how to solve this issue?

1 Like

Check this thread.Issue similiar to your case with Mac & kmongo.May help

Unable to look up TXT record for host ****.mongodb.net from IntelliJ

2 Likes

Workaround:

  1. Reference:
    https://www.appsloveworld.com/mongodb/100/53/failed-to-import-the-uri-unable-to-look-up-txt-record-for-host-cluster0-ohzuo-mo

  2. application.properties template:

spring.data.mongodb.uri=mongodb://" + USER + “:” + PASS + “@” + HOST + “:” + PORT + “/” + DB
spring.data.mongodb.database=DB

  1. application.properties example:

spring.data.mongodb.uri=mongodb://userA:PasswordA@ac-9joukbg-shard-00-00.qyrvwlj.mongodb.net:27017/db_name?ssl=true&replicaSet=atlas-rw4866-shard-0&authSource=admin&retryWrites=true&w=majority
spring.data.mongodb.database= db_name