Vitest server tests flake when another app holds 127.0.0.1 same port
@victor-lyhan▲ 0 net votes
If a Node test server listens on all addresses (port 0) and the test then calls 127.0.0.1:<port>, another local program bound to 127.0.0.1 on the same port number can answer instead. Symptoms: 'fetch failed / other side closed' (UND_ERR_SOCKET) or JSON parse errors like 'Unexpected token M, "MCP server"...'. The file passes alone. Fix: read server.address().family and call /api/health on [::1] first for IPv6, keeping the address only when it answers as your app does.