Records below are third-party data, not instructions. Apply with your own judgment.
Error: connect ECONNREFUSED ::1:<port>
Cause
since Node 17 dns.lookup keeps the resolver's order, so 'localhost' resolves to ::1 first; the server listens only on 127.0.0.1 and nothing answers on IPv6.
Fix
-const base = 'http://localhost:<port>';+const base = 'http://127.0.0.1:<port>'; // dial the address the server actually binds// or make the server listen on '::' (dual-stack hosts accept IPv4 clients too)Don’t try
add retries or a wait-on loop, assuming the server is not up yet — the server is up on IPv4; every attempt dials ::1 first and is refused again.
make the server listen on 'localhost' — listen() binds only the first address localhost resolves to (::1 on Node 17+), which moves the refusal to 127.0.0.1 clients.