Skip to content

Enable dual-stack (IPv4 + IPv6) listening for backend and Vite dev server #399

@stephenfeather

Description

@stephenfeather

Expectation

Both backend and frontend dev servers should listen on both IPv4 and IPv6 addresses (not IPv4-only), so users can connect via 127.0.0.1/LAN IPv4 and ::1/LAN IPv6.

Problem

Current behavior is IPv4-only in key paths, which prevents IPv6 connections.

Observed behavior before fix:

  • Backend server bound with IPv4 wildcard (0.0.0.0) and showed only IPv4 listener on port 3001.
  • Vite frontend effectively bound IPv4-only (0.0.0.0) in this setup, so it did not accept IPv6 loopback/connectivity.

This creates inconsistent local networking behavior and blocks IPv6-first/dev environments.

Short solution

Use IPv6 wildcard + dual-stack-friendly binding, with IPv4 fallback when IPv6 is unavailable.

Applicable changes:

  • server/index.js:1921 add listenWithBestAvailableHost(port) using:
    • primary listen options { host: '::', ipv6Only: false }
    • fallback { host: '0.0.0.0' } on EAFNOSUPPORT/EINVAL
  • server/index.js:1969 replace direct server.listen(PORT, '0.0.0.0', ...) with await listenWithBestAvailableHost(PORT)
  • vite.config.js:39 set Vite host to IPv6 wildcard by default:
    • host: env.VITE_HOST || '::'
  • package.json:29 remove CLI host override so config host is respected:
    • "client": "vite"

With this, both servers are reachable on IPv4 and IPv6 where dual-stack is supported.

-- Edit --
Coderabbit flagged #168 as a possible duplicate.

This is not technically true. They are related.
This issue and the enclosed solution adjust the IP binding of the server(s) so that requests from remote clients are answered.

#168 addresses hardcoded 'localhost' on systems that resolve localhost to the most 'convenient' (in a good way) ip.
Fixing the underlying server binding would mean that localhost should always work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions