'mongodb connection error with node and express

mongodb connection error with node and express. The error:

    at QueryReqWrap.onresolve [as oncomplete] (dns.js:206:19) {
  errno: undefined,
  code: 'ECONNREFUSED',
  syscall: 'querySrv',
  hostname: '_mongodb._tcp.clustr0-a1rol.mongodb.net'
}


Solution 1:[1]

Here are some possible issues with this case:

  • Check your IP address is whitelisted with your MongoDB client
  • Check your connection URI once again to check the possible error with that.

Please check this other problem and solution. link

Solution 2:[2]

I have faced the same issue, whatever I done is:

  1. restart my node server.
  2. change my database user.
  3. change my network and waiting sometime.
  4. then tried to connect.
  5. this time mongo connection was fine.

N.B- you can check your connection URI too, if its ok. then try with a different network.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nayan
Solution 2 Rashed