nodejs / nodejs/node

Subdomains on localhost return ENOTFOUND on some OS.

Open
#50,871 17 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

dns
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

Version

Tested on v21.2.0, v20.9.0, v18.18.2

Platform

Microsoft Windows NT 10.0.19045.0 x64

Subsystem

No response

What steps will reproduce the bug?
  1. run fetch("http://test.localhost/")
How often does it reproduce? Is there a required condition?

Happens on windows every time

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

Expected behaviour is ECONNREFUSED or content of what the webpage contains equally to how a node on Linux, cURL or a browser would handle it

What do you see instead?
Uncaught [TypeError: fetch failed] {
  cause: Error: getaddrinfo ENOTFOUND test.localhost
      at GetAddrInfoReqWrap.onlookupall [as complete] (node:dns:118:26)
      at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'test.localhost'
  }
}
Additional information

Recreated locally in a VM but also on an actual Windows device

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing fetch("http://test.localhost/") on Windows and inspect the node:dns resolution path that produces ENOTFOUND for test.localhost. Compare the behavior with Linux, cURL, or a browser, and consider the issue done when the Windows behavior matches the expected localhost handling with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.