dev: false "reachable from the network" warning when `devServer.host` is a `*.localhost` subdomain
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #1649 by @paoValle — closed without merging
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- cli, networking
Research direction
Find the listen implementation and the two checks using LOOPBACK_HOSTS.has(hostname), which drive the warning and the Network: hint. Read those checks and look for existing tests covering host classification or dev server output. Treat .localhost subdomains as loopback in both places; done when they no longer trigger the network warning or appear as network URLs.
Written by the indexing model from the issue text.
Description
Environment
@nuxt/cli: 4.0.1nuxt: 4.6.2- Node.js: 24.21.0
- OS: macOS
Reproduction
// nuxt.config.ts
export default defineNuxtConfig({
devServer: { host: 'my-app.localhost' },
})
nuxt dev
Describe the bug
The CLI prints:
The dev server is reachable from the network without authentication: anyone who can connect can read the app, build errors and source code.
The server is not reachable from the network. my-app.localhost resolves to loopback only (dns.lookup('my-app.localhost', { all: true }) returns ::1 and 127.0.0.1), so the listener is bound to loopback just like with localhost.
Per RFC 6761 §6.3, localhost and every name under .localhost resolve to loopback. Browsers resolve them that way without DNS and treat them as secure contexts. *.localhost names are a common way to run several local apps side by side.
Cause
In listen the warning only checks an exact-match set:
const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '::1'])
// ...
if (announce && (anyHost || !LOOPBACK_HOSTS.has(hostname))) logger.warn('The dev server is reachable from the network ...')
my-app.localhost is not in the set, so it is treated as a public host. The same check also drives the Network: hint shown under the URLs.
Suggested fix
Treat any .localhost name as loopback, e.g.:
const isLoopbackHost = host => LOOPBACK_HOSTS.has(host) || host.endsWith('.localhost')
and use it in both places that currently call LOOPBACK_HOSTS.has(hostname).
Workaround
Leave devServer.host unset and pass --publicURL http://my-app.localhost:3000 to nuxt dev, so the CLI shows that URL without the warning.
- Dominant language
- TypeScript
- Stars
- 402
- Forks
- 125
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 37
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nuxt/cli
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
Maintainers usually reply within 1 day
Similar issues
-
bug priority: low role: BE stage: now
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
ahmadrosid/nakama#2594 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
milind-soni/OpenMausBot#6495 ·
Maintainers usually reply within 1 day
-
Navigating the session tree adds the branch's prompts to Up-arrow history againPossibly taken @acmerfight claimed this today. Openuntriaged
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
earendil-works/pi#12279 ·
Maintainers usually reply within 1 day
-
approved documentation
Difficulty 1/5 Under an hour Newbie friendliness 89/100
vitest-dev/vitest#12015 · 4 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100