Skip to content

[BUG] Dev webview shows 'server is not running' when localhost resolves to ::1 #1588

Description

@hnbdr

Problem (one or two sentences)

In development mode, Zoo Code shows "Local development server is not running, HMR will not work. Please run 'npm run dev' before launching the extension to enable HMR." even though the Vite dev server is up and listening. The root cause is that localhost is ambiguous: on some systems it resolves to the IPv6 address ::1 first, while the dev server is bound to IPv4 — so requests addressed to localhost never reach it.

Context (who is affected and when)

Contributors running the extension from source in dev mode, on machines where localhost resolves to ::1 before 127.0.0.1. On affected systems, Resolve-DnsName localhost answers with AAAA first:

Name        Type   TTL   Section    IPAddress
----        ----   ---   -------    ---------
localhost   AAAA   1200  Question   ::1
localhost   A      1200  Question   127.0.0.1

Both sides of the dev loop use the name localhost: ClineProvider.getHMRHtmlContent() probes http://localhost:<port> and injects http://localhost:<port>/@react-refresh into the webview, while the Vite dev server is configured with hmr.host: "localhost". Depending on how each side resolves the name (IPv4 bind vs IPv6-first client resolution, and Node's verbatim DNS ordering), the probe connects to [::1]:<port> while nothing is listening there — the request fails, and the extension reports the dev server as not running. The issue is system-dependent (it only manifests where localhost prefers ::1), so it does not reproduce everywhere. Release builds are not affected because the webview is served from disk, not over the network.

Reproduction steps

  1. Windows 10/11, Node 17+ (default --dns-result-order=verbatim), on a system where localhost resolves to ::1 first (Resolve-DnsName localhost shows the AAAA record listed above).
  2. pnpm install, then pnpm dev (starts the Vite webview dev server on port 5173).
  3. Launch the extension host in development mode (F5 / the dev launch config).
  4. Open the Zoo Code sidebar.
  5. Observe: the error popup "Local development server is not running, HMR will not work..." appears even though the Vite server is running — the await axios.get("http://localhost:5173") health check in getHMRHtmlContent() gets connection-refused because localhost resolved to [::1]:5173 while Vite serves on IPv4.

Expected result

The dev webview loads with HMR regardless of whether the system resolves localhost to ::1 or 127.0.0.1.

Actual result

The health check against http://localhost:<port> fails on IPv6-first systems, the "local dev server is not running" error is shown, and the webview falls back / stays blank even though the dev server is running.

Variations tried (optional)

  • Making localhost resolve to IPv4 first (e.g., ordering the hosts file so 127.0.0.1 localhost wins) makes the problem disappear, which confirms the resolution mismatch is the trigger.
  • Using explicit 127.0.0.1 instead of localhost on both sides (dev-server host and the extension's probe/HMR URLs) fixes it deterministically.

App Version

3.82.0 (dev build, HMR mode)

API Provider (optional)

Not Applicable / Other

Model Used (optional)

N/A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions