Connection to the Atlas doesnt give any response

Hello guys. I just started learning working on mongodb atlas with nodejs and i am facing this issue when i try to connect to the cluster . I have enabled connection from anywhere and it still dosent work.

Here is the code and the output:

const MONGO_URL = "mongodb+srv://";
async function connectandRun() {
    await mongoose.connect(MONGO_URL)
    console.log("DB COnnected!")
  catch (error){
    console.error("Something went Wrong:",error);


Something went Wrong: Error: querySrv ETIMEOUT
    at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/promises:251:17) {
  errno: undefined,
  code: 'ETIMEOUT',
  syscall: 'querySrv',
  hostname: ''

Your insight would help.Thank you!

Hi @Abhiram_Gargeya,

Your DNS servers are timing out on looking up the SRV records for the cluster. Maybe change your DNS servers.

They resolve fine for me

dig +short  srv; dig +short txt
0 0 27017
0 0 27017
0 0 27017
1 Like

FYI I’ve written this up in more detail at querySrv errors when connecting to MongoDB Atlas | ALEX BEVILACQUA.


Hey , thanks for your insight . It did work. I changed the DNS server to Google Public DNS and it worked.Thanks once again for such a fast response .


Hey @alexbevi , thanks for the Blog link . It is very informative.

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