querySrv ECONNREFUSED

Hi @A.T_Rayan,

Error: querySrv ECONNREFUSED _mongodb._tcp.xxxcluster.v1ulb.mongodb.net
at QueryReqWrap.onresolve [as oncomplete] (dns.js:203:19) {
errno: undefined,
code: ‘ECONNREFUSED’,

The error indicates a possible SRV lookup failure.

Could you try using the connection string from the connection modal that specifies all 3 hostnames instead of the SRV record? To get this, please head to the Atlas UI within the Clusters section and follow the below steps:

  1. Click Connect on the cluster you wish to connect to
  2. Select Connect your application
  3. Choose Node.JS for the Driver option
  4. Choose the *Version 2.2.12 or later for the version option
  5. Copy and use the connection string which should begin with the following format:
    mongodb://<username>:<password>....

Replace the original connection string you used with the version 2.2.12 or later node.js connection string copied from the above steps and then restart your application.

If it returns a different error, please send that error here.

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

Note: although the above workaround may allow you to connect, it may be better to resolve any DNS issues into why the SRV record lookup is failing.

Best Regards,
Jason

27 Likes