Can Mercurial be configured to bind hg serve to localhost by default?
0 reputation · 03 Jun 2020, 13:50 UTC
The goal is to prevent Mercurial’s built‑in web server from unintentionally serving repositories on non‑loopback interfaces. By default, `hg serve` listens on 0.0.0.0:8000, making the repository reachable to any host on the network without emitting a warning when the bind address is not localhost.
Although the documentation highlights this exposure risk, the default bind address has not been altered, and the `-a/--address` flag must be supplied each time the server is started. Ongoing debate in the Mercurial community about switching the default to localhost‑only has not produced a consensus in the 6.x series, leaving the behavior uncertain for users who want a safer out‑of‑the‑box experience.
Can a global configuration option be added to make `hg serve` bind to localhost by default? Would changing the default address affect existing workflows that rely on public access via the built‑in server?