-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
Closed
Description
When express.js generates app.js to start the Express server on a port (default 3000), it throws an exception if the port is already in use. So instead, the error could be caught with the following check and produce a more descriptive error message, by changing:
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
to:
server = http.createServer(app);
server.once('error', function(err) {
if (err.code == 'EADDRINUSE') {
console.log(err.code + ': ' + app.get('port') + ' already in use');
}
});
server.listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
Metadata
Metadata
Assignees
Labels
No labels