Skip to content

Instantly share code, notes, and snippets.

@Sequoia
Created January 21, 2016 18:13
Show Gist options
  • Save Sequoia/fd24648ebef15130e9e5 to your computer and use it in GitHub Desktop.
Save Sequoia/fd24648ebef15130e9e5 to your computer and use it in GitHub Desktop.
Why doesn't this hit the callback for a2?
var express = require('express')
var a1 = express();
var a2 = express();
a1.listen(3000, function(err){
if(err){ console.error('a1 ERROR!!'); }
else{ console.log('Server a1 started on port 3000'); }
});
a2.listen(3000, function(err){
//expect to log 'a2 ERROR!!'
if(err){ console.error('a2 ERROR!!'); }
else{ console.log('Server a2 started on port 3000'); }
});
Server a1 started on port 3000
events.js:141
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::3000
at Object.exports._errnoException (util.js:860:11)
at exports._exceptionWithHostPort (util.js:883:20)
at Server._listen2 (net.js:1234:14)
at listen (net.js:1270:10)
at Server.listen (net.js:1366:5)
at EventEmitter.listen (/Users/sequoia/projects/code-along/my-express-app/node_modules/express/lib/application.js:617:24)
at Object.<anonymous> (/Users/sequoia/projects/code-along/my-express-app/foo.js:11:4)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment