Getting DNS name not found error

Hi Team,

I am getting this error while running the test case, few minutes back it is working fine and suddenly I start getting this error.
Successfully able to connect to cluster through compass and shell.
I have not changed any configuration since I download the mflix application.


Test set: mflix.api.daos.GetCommentsTest

Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 5.597 s <<< FAILURE! - in mflix.api.daos.GetCommentsTest
testGetMovieComments(mflix.api.daos.GetCommentsTest) Time elapsed: 0.001 s <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘mongoClient’ defined in mflix.config.MongoDBConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.client.MongoClient]: Factory method ‘mongoClient’ threw exception; nested exception is com.mongodb.MongoConfigurationException: Unable to look up SRV record for host cluster0.9tbhc.mongodb.net
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.client.MongoClient]: Factory method ‘mongoClient’ threw exception; nested exception is com.mongodb.MongoConfigurationException: Unable to look up SRV record for host cluster0.9tbhc.mongodb.net
Caused by: com.mongodb.MongoConfigurationException: Unable to look up SRV record for host cluster0.9tbhc.mongodb.net
Caused by: javax.naming.NameNotFoundException: DNS name not found [response code 3]

Are there any changes that happened in between this time? Like VPN, firewall, or any code changes?

Kanika

Thanks @kanikasingla
Nice catch, yes it’s the VPN that is causing the problem.

I am from China…Try to connect to cluster0.x4oml.mongodb.net. But it always show ‘Unable to look up TXT record for host cluster0.x4oml.mongodb.net’…Very sad that I can not connect

Hi @Joshua_Wang,

Can you please share the MongoDB connection string and the screenshot of the error you are facing? It will help us to help you further!

Thanks,
Kushagra

That should work. See:

https://toolbox.googleapps.com/apps/dig/#TXT/cluster0.x4oml.mongodb.net

Perhaps your Internet provider or VPN or firewall prevents you to access modern SRV DNS record.

Try using 8.8.8.8 as DNS resolver.

Hi Kushagra,
My string is mongodb+srv://cluster0.x4oml.mongodb.net/myFirstDatabase?authSource=%24external&authMechanism=MONGODB-X509&retryWrites=true&w=majority

Hi @Joshua_Wang,

Have you tried what steevej suggested

I hope it helps!

Thanks,
Kushagra