The issue is that .listen is asynchronous. By calling .close immediately after calling .listen, you are closing it before it has been opened.
Try this instead.
server.listen(8080, function() {
server.close();
});
The issue is that .listen is asynchronous. By calling .close immediately after calling .listen, you are closing it before it has been opened.
Try this instead.
server.listen(8080, function() {
server.close();
});