Error - Not able to connect to mongodb server

[nodemon] starting `node app.js`
server is listening on port 8000.......
Error: querySrv EREFUSED _mongodb._tcp.cluster1.qm7glq1.mongodb.net
    at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/callback_resolver:47:19) {
  errno: undefined,
  code: 'EREFUSED',
  syscall: 'querySrv',
  hostname: '_mongodb._tcp.cluster1.qm7glq1.mongodb.net'
}

Hi @Anurag_Gupta2,

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. Please refer to the Public DNS for more details.

Apart from this, please refer to this post and try using the connection string from the connection modal that includes all three hostnames instead of the SRV record.

If it returns a different error, please share that error message here.

In addition to the above, I would recommend also checking out the Atlas Troubleshoot Connection Issues documentation.

Best regards,
Kushagra