Connection to database DNS Error

Hi,

Hi, I’m trying connect to the mongodb atlas on my spring boot application 2.7 but I’m getting this error.

Not working even on localhost with google dns resolver.

Caused by: com.mongodb.spi.dns.DnsException: DNS error

Does anyone know how to fix it?

Thanks

Its your DNS server causing the error. Change DNS to google . If you are on a linux or mac

sudo nano /etc/resolv.conf

change name server to 8.8.8.8
This will work instantly. Also in your MongoDB clusters allow connection from anywhere. Once in production you can allow from your production APIs.

I had the same problem chatGTP gave me this solution. It worked for me.

1 Like

FRIEND!!! Thanks!!! I had this problem for months!! Thank you very much!!!