From 5430e727534275d3edc704bc64324130310ff66a Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Tue, 9 Sep 2014 14:20:31 +0000 Subject: [PATCH] Handle EADDRINUSE no ref - Show a human readable message on EADDRINUSE --- core/server/GhostServer.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/server/GhostServer.js b/core/server/GhostServer.js index 27e3acb96d..fbb19c256c 100644 --- a/core/server/GhostServer.js +++ b/core/server/GhostServer.js @@ -123,6 +123,17 @@ GhostServer.prototype.start = function (externalApp) { ); } + self.httpServer.on('error', function (error) { + if (error.errno === 'EADDRINUSE') { + console.log('ERROR: Cannot start Ghost. Another program is already using this port (is another Ghost instance already running?)'.red); + } else { + console.log( + 'ERROR: There was an error starting your server. '.red, + ('(Code: ' + error.errno + ')').red + ); + } + process.exit(-1); + }); self.httpServer.on('connection', self.connection.bind(self)); self.httpServer.on('listening', function () { self.logStartMessages();