querySrv ECONNREFUSED

PLEASE HELP L L :frowning: few days i try to solve this issue but no success resolved
i try to connect my node js app Back-end to mongodbatlas

Error: querySrv ECONNREFUSED _mongodb._tcp.xxxcluster.v1ulb.mongodb.net
at QueryReqWrap.onresolve [as oncomplete] (dns.js:203:19) {
errno: undefined,
code: ‘ECONNREFUSED’,
syscall: ‘querySrv’,
hostname: ‘_mongodb._tcp.xxxcluster.v1ulb.mongodb.net’
}
C:\Users\xxx\touch7\BackEnd\node_modules\mongodb\lib\utils.js:691
throw error;

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.

Best Regards,
Jason

4 Likes

I love you !! Seriously !! You saved me and made me the whole week
Thank you very much and even though I tried your solution before and it did not work properly maybe
because the function of creating a collection had something in it that disrupted the query process

AGAIN!!! THANK U A LOT

3 Likes

Thanks for your kind words & confirming that the issue is resolved.

Hope you continue to enjoy using MongoDB.

Best Regards,
Jason

2 Likes

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