#11098: Support dual-stack custom and LAN gateway binds
gateway
stale
Cluster:
Gateway Resilience and Configuration
This change enables IPv4+IPv6 dual-stack binding for custom and LAN modes. When bindHost is 0.0.0.0, the gateway additionally tries to bind :: and listens on both stacks if available. Custom bind hosts now accept IPv6 addresses as valid targets, while the existing fallback behavior remains unchanged when binding is not possible.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates gateway networking utilities to support dual-stack binds in LAN/custom modes:
- `resolveGatewayBindHost` now treats both IPv4 and IPv6 literals as valid custom bind targets.
- `resolveGatewayListenHosts` expands `127.0.0.1` to also listen on `::1` when possible, and expands `0.0.0.0` to also listen on `::` when possible.
- Tests were updated to cover the new LAN dual-stack behavior.
These functions are used by the gateway startup/runtime path (e.g. `src/gateway/server-runtime-state.ts`) to decide which addresses the HTTP/WebSocket server(s) bind to.
<h3>Confidence Score: 3/5</h3>
- This PR is close to safe to merge, but has a couple behavior changes/leaks that should be fixed first.
- Core dual-stack logic looks consistent with how bind hosts are consumed, and tests cover the new `0.0.0.0` => `::` behavior. Remaining concerns are (1) a breaking change for custom binds that previously could use hostnames but now reject them, and (2) `canBindToHost` not closing the server on error, which can leak handles in error cases/repeated calls.
- src/gateway/net.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#6113: support ipv6
by DingProg · 2026-02-01
83.0%
#19437: Gateway: respect custom bind host for local health/RPC target resol...
by frudas24 · 2026-02-17
80.9%
#22056: fix(gateway): use loopback for self-connections regardless of bind ...
by usedhonda · 2026-02-20
76.4%
#16300: fix(tui): respect gateway bind mode in TUI connection
by cortexuvula · 2026-02-14
75.4%
#14564: fix(gateway): crashes on startup when tailscale meets non-loopback ...
by yinghaosang · 2026-02-12
75.1%
#19026: fix(gateway): use loopback for local CLI-to-gateway connections
by Phineas1500 · 2026-02-17
74.9%
#19429: Fix/custom bind host validation
by frudas24 · 2026-02-17
74.1%
#23688: fix(gateway): accept raw IP addresses in gateway.bind for backward ...
by arosstale · 2026-02-22
73.6%
#22110: fix(tools): prefer loopback for internal tool-to-gateway RPC calls
by pierreeurope · 2026-02-20
73.2%
#7654: feat(security): zero-trust localhost auth with DNS rebinding protec...
by joncode · 2026-02-03
72.6%