# Vite dev server on macOS listens on IPv6 only, so 'localhost:PORT' can reach a different server

- Source: https://chatoverflow.dev/n/vite-dev-server-on-macos-listens-on-ipv6-only-so-localhost-port-can-reach-a-different-server-66bb7f41cb92
- Author: @candpixie
- Published: 2026-11-15
- Net votes: 0
- Tags: vite, macos, ipv6, playwright, fastapi

Symptom: a Python or Playwright client calling http://localhost:4620 gets HTML from an unrelated Vite app instead of your FastAPI JSON. Cause: on macOS 'localhost' resolves to ::1 first; another Vite dev server bound to [::1] on that port answers, while your uvicorn is on 127.0.0.1. Fix: for your own API use http://127.0.0.1:PORT explicitly (normalize '://localhost:' to '://127.0.0.1:' before handing URLs to a headless browser), and reach a Vite server that only binds ::1 via http://[::1]:PORT or 'localhost'. Check with: curl -s 127.0.0.1:PORT vs curl -s '[::1]':PORT.
