Unable to connnect to my MongoDB Atlas

Error: queryTxt ETIMEOUT cluster0.xxxxxxx.mongodb.net
    at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/promises:252:17) {
  errno: undefined,
  code: 'ETIMEOUT',
  syscall: 'queryTxt',
  hostname: 'cluster0.xxxxxxx.mongodb.net'
}

when i connect to my atlas it giving this error and i have no idea what its about so i cant debug it, it just happened suddenly coz it was working okay before all this

here is how am connecting to the atlas:


const connect = async () => {
  try {
    await mongoose.connect(process.env.MONGODB_URI, {
      useNewUrlParser: true,
      useUnifiedTopology: true,
    });
    console.log('Connected to mongoDB Atlas!');
  } catch (error) {
    console.log(error);
  }
};
connect().then(() => {
  try {
    app.listen(process.env.PORT, () => {
      console.log(`Server running on port ${process.env.PORT}`);
    });
  } catch (error) {
    console.log(error);
  }
});

here is my URI:

MONGODB_URI = mongodb+srv://yyyyyyyyy:xxxxxxxxxx@cluster0.gdrr9qe.mongodb.net/?retryWrites=true&w=majority

Hi @iSteven_Zion_N_A,

Welcome to the MongoDB Community :star2:

It seems like the DNS issue, try using Google’s DNS 8.8.8.8 and 8.8.4.4. Also, you can refer to one of responses here to learn more about it.

In case you’re still encountering further issues whilst connecting, please provide any error messages received.

Best regards,
Kushagra