Skip to content

fix(dev): use 127.0.0.1 instead of localhost for dev server (IPv6 resolution) - #1589

Open
hnbdr wants to merge 1 commit into
Zoo-Code-Org:mainfrom
hnbdr:fix/localhost-ipv6
Open

fix(dev): use 127.0.0.1 instead of localhost for dev server (IPv6 resolution)#1589
hnbdr wants to merge 1 commit into
Zoo-Code-Org:mainfrom
hnbdr:fix/localhost-ipv6

Conversation

@hnbdr

@hnbdr hnbdr commented Sep 10, 2026

Copy link
Copy Markdown

Closes: #1588

Description

On systems where localhost resolves to ::1 before 127.0.0.1, the dev-mode webview fails to load: the axios.get("http://localhost:<port>") health check in getHMRHtmlContent() never reaches the Vite dev server, so Zoo Code shows "Local development server is not running..." even though the server is up.

Fix is to stop relying on the ambiguous localhost name in the dev loop and pin both sides to IPv4:

  • src/core/webview/ClineProvider.ts: localServerUrl and the injected @react-refresh import URL now use 127.0.0.1 instead of localhost. This also keeps the CSP entries (script-src/connect-src/style-src, which are derived from localServerUrl) consistent with what the webview actually loads.
  • webview-ui/vite.config.ts: bind the dev server explicitly with host: "127.0.0.1", keep hmr: true (HMR now derives host/port from the server config instead of a separate hmr.host: "localhost"), pin port: 5173, and move the ws.protocol: "ws" setting under server.ws since HMR is no longer an object.

Design note: choosing 127.0.0.1 over ::1 matches the existing 0.0.0.0 fallback already present in the CSP and is deterministic on Windows where Node 17+ uses verbatim DNS ordering.

Test Procedure

  • pnpm --dir src exec eslint --max-warnings=0 core/webview/ClineProvider.ts and webview lint — clean.
  • tsc -b in webview-ui — clean.
  • Full pnpm lint and pnpm check-types (turbo, all packages) via pre-commit/pre-push hooks — pass.
  • Manual: on an affected machine (Resolve-DnsName localhost returns AAAA ::1 first), run pnpm dev + launch the extension host, open the sidebar — the webview loads with working HMR and no "server is not running" error. Also verified the normal IPv4-first path still works.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Visual Snapshot (UI changes only): N/A — dev-server wiring only, no rendered UI change.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Visual Snapshots

N/A — no user-facing rendered state changes; this only affects the dev-mode bootstrap.

Videos (interaction / animation only)

N/A.

Documentation Updates

  • No documentation updates are required.

Additional Notes

No unit test added: the touched code path is dev-only bootstrap (getHMRHtmlContent + Vite server config) with no existing test harness around it; coverage is the manual repro in #1588.

Get in Touch

hnbdr

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • coderabbit-review-active

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 455f73f8-d488-472e-b28e-b0394871072a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Review status

Thanks for contributing. This comment tracks the review sequence and the next action.

Current step: Required CI passed. Waiting for automated review of the latest commit.

If automated review does not start, a maintainer must restart it.

Review-state labels are managed by this workflow; do not edit them manually.

@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/core/webview/ClineProvider.ts 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@hnbdr
hnbdr marked this pull request as ready for review September 10, 2026 12:42
@github-actions github-actions Bot added coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit labels Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit coderabbit-review-active Required CI passed; CodeRabbit review is active

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant