Skip to main content
  1. About
  2. Stack Internal
The 2026 Annual Developer Survey is live— take the Survey today!

Timeline for answer to MongoDb Connection failed : Error: querySrv ECONNREFUSED by Sudarsan Sarkar

Current License: CC BY-SA 4.0

Post Revisions

9 events
when toggle format what by license comment
Jun 8 at 17:43 comment added Allan Munene on my mongoose.ts file, i just pasted added "require("node:dns/promises").setServers(["1.1.1.1", "8.8.8.8"]); " at the top of the file before adding any imports .
May 17 at 0:39 comment added Muhammed Shamal Thanks, a lot for this answer, const dns = require("node:dns/promises"); dns.setServers(["1.1.1.1", "1.0.0.1"]); after using this dns perfectly works my server.
Apr 29 at 5:56 comment added Kalzang Dorje Lama If you're on Node 20+ with mongodb+srv://, try forcing public DNS before connecting: js import dns from "node:dns"; dns.setServers(["1.1.1.1", "1.0.0.1"]); await mongoose.connect(MONGO_URI); This fixes querySrv ECONNREFUSED caused by SRV lookup failures in newer Node.js DNS resolver. Only affects the current process, not system DNS.
Feb 17 at 10:18 comment added Shiv Yadav Thanks — the issue was with the Node.js version. After switching to version 20.9.0, everything is working correctly.
Jan 27 at 7:21 vote accept Sudarsan Sarkar
S Jan 26 at 2:01 review First answers
Jan 26 at 2:04
S Jan 26 at 2:01 history edited tdy CC BY-SA 4.0
added 2 characters in body
S Jan 25 at 20:10 review First answers
Jan 25 at 20:28
S Jan 25 at 20:10 history answered Sudarsan Sarkar CC BY-SA 4.0

AltStyle によって変換されたページ (->オリジナル) /