You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dns.getServers() incorrectly returns 127.0.0.1 when OS DNS is configured to 8.8.8.8 #62347
Current Version: 24.14.0, Same Issue on Every version of nodejs
Platform
Windows, x64
Subsystem
No response
What steps will reproduce the bug?
Set system DNS to a public resolver (e.g., 8.8.8.8) on Windows.
Verify 'ipconfig /all' shows 8.8.8.8 as the only DNS server.
Run the following command in a clean terminal:
node -e "console.log(require('node:dns').getServers())"
Observe that it returns ['127.0.0.1'] despite system settings.
How often does it reproduce? Is there a required condition?
Always (100% of the time) on this specific machine after a PC reset, even after clearing virtual network adapters and setting the Interface Metric for Wi-Fi/Ethernet to 1.
What is the expected behavior? Why is that the expected behavior?
The 'dns.getServers()' method should return the DNS servers configured in the OS network stack (8.8.8.8). It should not default to the loopback address (127.0.0.1) when a valid external DNS is active and prioritized.
What do you see instead?
The output of node -e "console.log(require('node:dns').getServers())" is ['127.0.0.1'].
This occurs even though ipconfig /all confirms the system is using 8.8.8.8 and no local DNS proxy (like Acrylic or Acrylic DNS) is running on port 53.
Additional information
I have already tried netsh winsock reset, ipconfig /flushdns, and netsh int ip reset.
I manually set the Interface Metric for the active Wi-Fi adapter to 1 to ensure priority.
I uninstalled all virtual network adapters (WSL2/Docker/VPN bridges).
nslookup google.com correctly identifies the server as 8.8.8.8, but Node.js remains stuck on the loopback address.
This behavior started immediately after a Windows PC reset.
This was happening despite ipconfig /all and nslookup -type=SRV both showing the correct DNS servers (8.8.8.8 / 1.1.1.1), and mongodb+srv:// connections failing with querySrv ECONNREFUSED.
What fixed it was forcing the resolver explicitly via a preload script instead of relying on Node picking up the system DNS on its own:
Two gotchas that cost extra time, in case they help someone else:
The machine-wide env var change didn't take effect until a full PC restart — a fresh terminal window alone wasn't always enough.
If you run from VS Code's integrated terminal, it can keep using a stale cached environment independently of the system-wide change. Needed this in VS Code's settings.json as well:
Activity
Renegade334 commentedon Mar 24, 2026
This was fixed in c-ares (c-ares/c-ares@8ba37af) but not yet released.
JUNED-AHMED-CHOUDHARY commentedon Jun 5, 2026
I can confirm this issue on Windows 11.
Environment:
Windows 11 24H2
Node.js v24.16.0
Also reproduced on v22.22.3
The global resolver reports:
require('dns').getServers()
['127.0.0.1']
and:
require('dns').resolve4('google.com', console.log)
fails with:
Error: queryA ECONNREFUSED google.com
However, a manually configured resolver works:
const dns = require('dns');
const r = new dns.Resolver();
r.setServers(['8.8.8.8']);
r.resolve4('google.com', console.log);
which successfully resolves the hostname.
dns.lookup() and nslookup also work correctly on the same machine.
Thanks for identifying the c-ares fix. I can confirm the behavior is still present in Node.js v24.16.0 and the latest version that is v23.6.0.
This issue is causing connecting to mongodb srv url using mongoose, if this is solved then I think relase of this bug fix would be great help.
deepak-cardoza commentedon Jun 24, 2026
Confirming I hit this exact symptom on a Windows 11 laptop — tested on both Node 24.x and Node 20.x, same behavior on both:
This was happening despite
ipconfig /allandnslookup -type=SRVboth showing the correct DNS servers (8.8.8.8 / 1.1.1.1), andmongodb+srv://connections failing withquerySrv ECONNREFUSED.What fixed it was forcing the resolver explicitly via a preload script instead of relying on Node picking up the system DNS on its own:
Two gotchas that cost extra time, in case they help someone else:
settings.jsonas well:Hope this saves someone else some debugging time.
deps: c-ares: cherry-pick 8ba37af8e3fb
deps: c-ares: cherry-pick 8ba37af8e3fb
deps: c-ares: cherry-pick 8ba37af8e3fb
deps: c-ares: cherry-pick 8ba37af8e3fb
deps: c-ares: cherry-pick 8ba37af8e3fb
deps: c-ares: cherry-pick 8ba37af8e3fb
deps: c-ares: cherry-pick 8ba37af8e3fb
deps: c-ares: cherry-pick 8ba37af8e3fb
deps: c-ares: cherry-pick 8ba37af8e3fb
deps: c-ares: cherry-pick 8ba37af8e3fb
deps: c-ares: cherry-pick 8ba37af8e3fb
chore(deps): require Node 24.19+, add compression, helmet and a rate …