preview_start breaks on Windows/Git Bash — autoPort returns "in use" for all free ports (regression)

Resolved 💬 1 comment Opened Jun 12, 2026 by hidamiki Closed Jun 12, 2026

Environment

  • OS: Windows 10 Home China 10.0.19045
  • Shell: Git Bash (MSYS2 MINGW64_NT-10.0.19045)
  • Claude Code: 2.1.139
  • lsof available: No — which lsof returns nothing
  • ss -tlnp: Executes but produces empty output (Git Bash limitation)
  • netstat -ano: Works correctly and reports accurate port state
  • PowerShell Get-NetTCPConnection: Works correctly

Summary

preview_start used to work on this machine (auto-port jumping worked correctly). Since a recent update, it now reports "Port X is in use" for every free port, making preview_start completely unusable.

Reproduction

  1. Confirm port 52358 is free:
  • netstat -ano | findstr :52358 → empty
  • Get-NetTCPConnection -State Listen | Where-Object LocalPort -eq 52358 → empty
  • Test-NetConnection 127.0.0.1 -Port 52358 → False
  • Python socket.bind(('', 52358)) → succeeds
  1. launch.json:
{
  "version": "0.0.1",
  "configurations": [{
    "name": "test",
    "runtimeExecutable": "python",
    "runtimeArgs": ["-m", "http.server", "{port}", "--bind", "127.0.0.1"],
    "cwd": "${workspaceFolder}",
    "port": 0,
    "autoPort": true
  }]
}
  1. preview_start("test") → "Port X is in use and automatic port reassignment failed"
  1. Bash("python -m http.server 52358") → works, returns 200

What Changed

This is a regression. Previously, preview_start successfully auto-picked ports and auto-jumped between them on this machine. Now it fails on every port.

Additional Observation

The ONLY time preview_start correctly detected port state was when a node.exe process was actively LISTENING on port 12345 — it correctly reported the PID and process name. But for free ports, it always reports "in use".

Likely Root Cause

Port detection logic likely relies on lsof/ss which are non-functional in MSYS2 Git Bash on Windows. The fallback to netstat (which works) may have been lost in a recent update.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗