dev: false "reachable from the network" warning when `devServer.host` is a `*.localhost` subdomain

Open Beginner friendly
#1,644 1 comment 0 reactions 0 assignees View on GitHub

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.1
  • nuxt: 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

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

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.

More from nuxt/cli

All issues in nuxt/cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.