Skip to content

dns.resolveSrv returns ECONNREFUSED on Windows since v24.13.0 (still broken in v25.x and v26.x) #62326

Description

@niridya

Version

v24.14.0, v25.8.1

Platform

Microsoft Windows NT 10.0.26200.0 x64

Subsystem

dns (c-ares)

What steps will reproduce the bug?

Run the following script:

const dns = require("dns");

dns.resolveSrv("_mongodb._tcp.mongodb.<your-cluster>.mongodb.net", (err, addresses) => {
  console.log(err ? `error ${err.code}: ${err.message}` : addresses);
});

Run with Node.js >= v24.13.0 on Windows.

How often does it reproduce? Is there a required condition?

100% reproducible on Windows.

No special conditions required.

What is the expected behavior? Why is that the expected behavior?

The SRV query should resolve successfully and return records.

Example output (Node v24.12.0 and v25.2.1):

[
  {
    name: 'shard-00-00.<your-cluster>.mongodb.net',
    port: 27017,
    priority: 0,
    weight: 0,
    type: 'SRV'
  },
  {
    name: 'shard-00-01.<your-cluster>.mongodb.net',
    port: 27017,
    priority: 0,
    weight: 0,
    type: 'SRV'
  },
  {
    name: 'shard-00-02.<your-cluster>.mongodb.net',
    port: 27017,
    priority: 0,
    weight: 0,
    type: 'SRV'
  }
]

This behavior is consistent with:

  • previous Node.js versions
  • Node.js v25.2.1
  • other platforms (tested on Linux)

What do you see instead?

error ECONNREFUSED: querySrv ECONNREFUSED _mongodb._tcp.<your-cluster>.mongodb.net

This happens consistently even with valid public DNS resolvers configured on the system.

Additional information

This appears related to the issue described in #61435 and the fix in #61453 (commit 17b363a).

However, the problem persists on Windows.

From testing:

  • Node.js 24:

    • Last known working version: v24.12.0
    • First broken version: v24.13.0+
  • Node.js 25:

    • Last known working version: v25.2.1
    • Reproducible in all tested versions up to v25.8.1

The issue is 100% reproducible and specifically affects SRV resolution (dns.resolveSrv).

The issue does not occur in earlier versions and is therefore a regression.

This suggests the fix may be incomplete or that the regression was reintroduced.

Activity

  1. mathsoft-dev commented on Mar 19, 2026

    @mathsoft-dev

    Yes, I'm having the same issue as before with the latest versions of 24 and 25 on Windows.

  2. sunjay-dev commented on Mar 21, 2026

    @sunjay-dev

    I’m seeing the exact same problem on Windows. When I use Node v24.11.0, my MongoDB connection works fine:

    Image

    But after upgrading to Node v24.14.0, the same code throws:

    Image
  3. dantongarrido commented on Apr 18, 2026

    @dantongarrido

    I have the same problem, can confirm the last working version on Node.js 24 is v24.12.0

  4. changed the title [-]dns.resolveSrv returns ECONNREFUSED on Windows since v24.13.0 (still broken in v25.x)[/-] [+]dns.resolveSrv returns ECONNREFUSED on Windows since v24.13.0 (still broken in v25.x and v26.x)[/+] on May 11, 2026
  5. niridya commented on May 11, 2026

    @niridya
    Author

    I tested this again on the latest Node.js 26 release, and the issue is still present.

    Environment:

    • Windows
    • Node.js v26.x

    dns.resolveSrv() still returns ECONNREFUSED exactly like in previous reports.

  6. Cherry commented on May 21, 2026

    @Cherry
    Contributor

    This also seems to impact other resolve functions too, like resolveMx:

    require('dns').resolveMx('example.com', console.log)
    • Node.js 24.15.0 response: Error: queryMx ECONNREFUSED example.com
    • Node.js 24.12.0 response: null [ { exchange: '', priority: 0, type: 'MX' } ]

    And even just:

    require('dns').resolve('example.com', console.log)
    • Node.js 24.15.0 response: Error: queryA ECONNREFUSED example.com
    • Node.js 24.12.0 response: null [ '172.66.147.243', '104.20.23.154' ]
  7. greguintow commented on Jun 1, 2026

    @greguintow

    @niridya I created the fix here:

    But it needed to be fixed upstream, which c-ares team already did, but they still haven't released the latest changes, I created the issue to follow up when it will be released:

    This is what I've been doing for now:

  8. niridya commented on Jun 2, 2026

    @niridya
    Author

    Thanks for the update and for tracking this upstream.

    That explains why I'm still seeing the issue on the current public Node.js v26.x release. I'll keep an eye on the c-ares release and the related PRs.

  9. yasharya2901 commented on Jun 13, 2026

    @yasharya2901

    I was using 26.3.0 version and the following command node -e "require('dns'); console.log(require('dns').getServers())" would result in [ '127.0.0.1' ].

    I switched to the previously installed version 24.12.0 for a correct DNS query, i.e., [ '192.168.1.1' ].

  10. divyam-1604 commented on Jun 29, 2026

    @divyam-1604

    Ran into this exact issue on Windows while connecting to MongoDB Atlas over a mobile data hotspot connection. Node's resolver completely fails on the SRV lookup, throwing ECONNREFUSED.

    For anyone looking for an immediate programmatic workaround in their code without changing their OS environment, you can force Node's engine to use public Google/Cloudflare servers at the application entry point.

    Placing this snippet at the absolute top of the entry file (before any database initialization) completely resolves the ECONNREFUSED failure:

    const dns = require("node:dns");
    dns.setServers(["1.1.1.1", "8.8.8.8"]);
  11. niridya commented on Jul 6, 2026

    @niridya
    Author

    Just a quick follow-up: according to the upstream c-ares issue, the fix has now been released in c-ares 1.34.7.

    Hopefully this unblocks the Node.js side of the fix. Thanks again for tracking this upstream.

  12. niridya commented on Jul 8, 2026

    @niridya
    Author

    I can confirm that this issue is no longer reproducible on the public Node.js v26.5.0 release on Windows. 🎉

    I also tested the latest active LTS releases:

    • v24.18.0: still reproducible
    • v22.23.1: still reproducible

    So at the moment, this appears to be fixed in the v26.x release line, while the current LTS release lines are still affected.

  13. niridya commented on Aug 3, 2026

    @niridya
    Author

    Quick update after testing the latest releases:

    • ✅ Fixed in Node.js v26.5.0
    • ✅ Fixed in Node.js v24.19.0
    • ❌ Still reproducible in Node.js v22.23.2
    • ⚠️ Still reproducible in Node.js v25.9.0, but this release line is now End-of-Life.
  14. niridya commented on Sep 24, 2026

    @niridya
    Author

    Quick update:

    • ✅ Fixed in Node.js v26.5.0
    • ✅ Fixed in Node.js v24.19.0
    • ✅ Node.js v22.23.3 now includes c-ares v1.34.8, which contains the upstream fix.

    I wasn't able to reproduce the issue on my new PC to independently confirm the fix on v22.23.3, but since the c-ares version containing the fix is now included, there shouldn't be any reason for the issue to persist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions