How do I shutdown a Node.js http(s) server immediately?
The trick is that you need to subscribe to the server’s connection event which gives you the socket of the new connection. You need to remember this socket and later on, directly after having called server.close(), destroy that socket using socket.destroy(). Additionally, you need to listen to the socket’s close event to remove it from … Read more