11ty / 11ty/dev-server

Dev server binds to all network interfaces (0.0.0.0) with no option to restrict to localhost

Open Beginner friendly
#128 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
109
Forks
20
Avg merge
1m
Merged PRs (30d)
1

Description

Summary

The dev server always binds to all network interfaces because _serverListen only passes port to Node's server.listen(), with no host parameter. There is no configuration option to change this. Users on networks that assign publicly routable IPs (university networks like eduroam, IPv6 networks, misconfigured routers, conference/hotel WiFi) are exposed to the internet with no warning.

The problem

In server.js, the listen call looks like this:

_serverListen(port) {
    this.server.listen({
        port,
    });
}

When no host is passed to Node's server.listen(), it defaults to 0.0.0.0 — meaning every network interface on the machine. There is no host option in setServerOptions and no --host CLI flag to override this.

The showAllHosts option does not restrict binding — it only controls whether additional IPs are displayed in the console output.

Why this matters

Most developers assume their dev server is only accessible locally. On many home networks, NAT accidentally provides that isolation. But this is not a safe default as there are many networks (such as lots of university networks) that have very little if any inbound filtering.

Suggested fix

Pass a host option through to server.listen(), defaulting to 127.0.0.1:

_serverListen(port) {
    this.server.listen({
        port,
        host: this.options.host || "127.0.0.1",
    });
}

This would:

  • Make the dev server secure by default (loopback only).
  • Allow users who need LAN access to opt in with host: "0.0.0.0" in setServerOptions.
  • Align with the behavior of essentially every other modern dev server.

Users who need to access their dev server from other devices (e.g., phone testing) can explicitly set host: "0.0.0.0" or use a tool like tailscale serve to proxy safely.

Contributor guide

No contributing guide indexed for this repository

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 in server.js at _serverListen and inspect how setServerOptions stores server configuration. Trace the existing server.listen call and the current showAllHosts behavior, then verify that the server defaults to localhost while an explicit host still permits LAN access. Done means the binding behavior matches the issue's security requirements and the documented configuration path works.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.