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

Hi all,
I’m failing to connect to my mongo atlas instance. Whenever I try to connect using the connection string provided by Atlas, I keep getting this exception:
Failed looking up TXT record for host ****.mongodb.net.

I’ve attempted to change my DNS server as recommended in this post but that didn’t resolve the issue.

I’m using the KMongo 4.6.0 which internally uses 4.6.0 mongo java driver.

Would anyone be able to help?

If you switched DNS provider and you still have a DNS issue then your URI is really wrong.

However, we cannot help you if you share a redacted version with the only important part replaced with stars. We need to see the real URI to figure out what is wrong.

If you really have stars in your URI, this is the error.

Hi Steeve, thanks for your response.

Regarding the URI, here is my real uri:

  • mongodb+srv://<username>:<password>@trellis-uat.tamwc.mongodb.net/?retryWrites=true&w=majority.

Thats the connection string I am given from the Atlas web portal. I’ve attached an image below for your reference. I do swap out the <username> & <password> parts of the URI for an actual username and password but yeah, it doesn’t work. What’s strange is I’ve used this connection string for the last two years or so and it’s worked fine up till about two or three months ago. Furthermore, I have deployed my application to external servers and it is running well on those servers. It can connect to the Mongo database even now but when I run the application on my PC, it fails to connect and keeps throwing the aforementioned exception.

I’ve tried changing the DNS on my computer (mac), I’ve tried using a VPN to when attempting to connect, I’ve verified that the 27017 is open, but yeah, the issue still persists, I cannot connect to the mongo instance when running my application on IntelliJ.

One final thing, I am able to connect to my atlas db if I use the MongoDB Compass application. I don’t know if that information is helpful but yeah, thought I would share it.

If you need me to, I can send you a username & password that you can use to attempt to connect to the Atlas instance.

Thanks again for your help.

We were not aware that you could connect (Compass or mongosh) from the same machine with the same connection string. Your original post did not mentioned that. This important fact rules out any DNS issues.

My question now returns to your original post where you mentioned:

Are the stars part of the error message or is the real cluster name is there? In other words is the error message really:

Failed looking up TXT record for host ****.mongodb.net

OR

Failed looking up TXT record for host trellis-uat.tamwc.mongodb.net

If IntelliJ is printing starts then it is a configuration issue and your code does not read correctly the current cluster name from your configuration. May be you do not start IntelliJ from the top directory of your project. May be the configuration file has the starts and you are supposed to changed it.

Hi steevej, thanks again for your response.

Regarding the question you’d asked

Are the stars part of the error message or is the real cluster name is there? In other words is the error message really:

the stars are not part of the error message. I put them in when making this post because I thought if there is a generic fix that doesn’t require me exposing the cluster name then I would go for that but as our discussion has progressed, I see that I was wrong to do that and that details are required to fix this problem.

Here is a photo of the error messge I’m getting (top exception)

Here is the underlying cause (underlying exception that is caught and then throws the one above :point_up_2:)

The exception underlying the one above: (root exception that is caught and then throws the one above :point_up_2:)

FYI:
Those screenshots are from sentry.io which is what I"m using to capture my exceptions. For some reason, intellij IDE doesn’t seem to have a good log that shows the exceptions when they are thrown.

I have no clue.

May be some package are outdated.

I would try without kmongo.

1 Like

Alright, I’ll give that a go

[For the sake of anyone who runs into this issue in the future]

So I believe I’ve found the root issue. It seems that this issue is caused by something going wrong in the tomcat server. Potentially it is not being started when the computer boots. I found the approximate time when this issue first emerged; it coincided with a mac OS upgrade. It may have been that something in the change prevented the Tomcat server from starting on boot.

Checking the status of the Tomcat server seems to have resolved the issue.

You can check the status of the Tomcat server by running:

ps -ef | grep tomcat

Another thing you should do is switch the JDK you’re using to the latest OpenJDK available.

The combination of doing those things seems to have resolved the issue for me.

This StackOverflow post was particularly helpful for me when debugging the problem.

1 Like

Please note that I also verified that this issue is not caused by a specific local environment, in other words, it is occurring on multiple macs running OS 12.4+. I also tried connecting to mongo via Android Studio and via Intellij (I created two different projects - one for Android & one in Intellij) and in both instances, it failed to connect but instead threw the same error. This would seem to indicate that the root issue is not because of the configuration of one particular computer or one particular program (Android Studio/Intellij).

It points to the issue being something caused by the OS as both computers that were used to test this were Macs running OS12.4+, thus leading me to conclude that something in the recent MacOS maybe causing this. Changes made may have impacted the running of the tomcat server.

1 Like

Had the same issue. I could connect through mongo shell, but not with kmongo in intellij. Also, I swithced from windows to mac device. Changing the SDK version to 1.8 seems to fix the issue. File → Project Structure → Project Settings → Project then download JDK and change SDK

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.