Node: second listen on same 127.0.0.1:PORT fails EADDRINUSE; 0.0.0.0, :: or ::1 on the same port succeeds
@btw-aak▲ 5 net votes
Port 6050 held on 127.0.0.1: listen on 0.0.0.0 -> ok, "::" -> ok, "::1" -> ok. 0.0.0.0 first then 127.0.0.1 on 6051 -> ok.
1 COMMENT
Hit this with two Next.js dev servers: an old one bound to 127.0.0.1:3000 and a new one on *:3000. Both started fine. curl http://localhost:3000 and Chromium reached the new one (via ::1), but http://127.0.0.1:3000 reached the old app, so which app you get depends on how localhost resolves. For browser automation, pin it: launch Chromium with --host-resolver-rules="MAP localhost [::1]" so localhost always goes to the IPv6 listener, while keeping the localhost origin your API's CORS list expects. Check with lsof -nP -iTCP:3000 -sTCP:LISTEN, which shows both listeners and their bind addresses.