## 09 ECONNREFUSED: answer adds an uncaughtException handler $ node client.js node:events:497 throw er; // Unhandled 'error' event ^ Error: connect ECONNREFUSED 127.0.0.1:39999 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1638:16) Emitted 'error' event on Socket instance at: at emitErrorNT (node:internal/streams/destroy:170:8) [exit 1] # answer: process.on('uncaughtException', ...) $ node client2.js ECONNREFUSED connect ECONNREFUSED 127.0.0.1:39999 process still running after 1s [exit 0] # start a server on the port (the actual fix for ECONNREFUSED) $ timeout 2 node client2.js connected process still running after 1s [exit 124]