Skip to content

Instantly share code, notes, and snippets.

@rockbot
Created March 13, 2012 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rockbot/2030472 to your computer and use it in GitHub Desktop.
Save rockbot/2030472 to your computer and use it in GitHub Desktop.
Error from deploying app to Nodejitsu for the first time
error: Error running command deploy
error: Nodejitsu Error (500): Internal Server Error
error:
error: There was an error while attempting to start your application.
error: Error spawning drone
error: Script prematurely exited
error:
error: This type of error is usually a user error.
error: Error output from your application:
error:
error: Warning: connection.session() MemoryStore is not
error: designed for a production environment, as it will leak
error: memory, and obviously only work within a single process.
error: node.js:201
error: throw e; // process.nextTick error, or 'error' event on first tick
error: ^
error: TypeError: Cannot read property 'port' of null
error: at Object.<anonymous> (/usr/local/src/rockbot/application-name/CrowdNotes/app.js:63:76)
error: at Module._compile (module.js:441:26)
error: at Object..js (module.js:459:10)
error: at Module.load (module.js:348:31)
error: at Function._load (module.js:308:12)
error: at Function.runMain (module.js:479:10)
error: at Array.0 (/root/haibu-orchestra/node_modules/haibu/node_modules/haibu-carapace/lib/carapace.js:190:30)
error: at EventEmitter._tickCallback (node.js:192:40)
error: Warning: connection.session() MemoryStore is not
error: designed for a production environment, as it will leak
error: memory, and obviously only work within a single process.
error: node.js:201
error: throw e; // process.nextTick error, or 'error' event on first tick
error: ^
error: TypeError: Cannot read property 'port' of null
error: at Object.<anonymous> (/usr/local/src/rockbot/application-name/CrowdNotes/app.js:63:76)
error: at Module._compile (module.js:441:26)
error: at Object..js (module.js:459:10)
error: at Module.load (module.js:348:31)
error: at Function._load (module.js:308:12)
error: at Function.runMain (module.js:479:10)
error: at Array.0 (/root/haibu-orchestra/node_modules/haibu/node_modules/haibu-carapace/lib/carapace.js:190:30)
error: at EventEmitter._tickCallback (node.js:192:40)
@rockbot
Copy link
Author

rockbot commented Mar 13, 2012

The solution here was simple: remove the last line in app.js:

console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);

As the nodejitsu guys mentioned, nodejitsu will take care of the port stuff on its own :-)

@rockbot
Copy link
Author

rockbot commented Mar 13, 2012

Covered this error and others like it in the following blog post: http://raquelvelez.com/blog/2012/03/deploying-to-nodejitsu/

@jfhbrook
Copy link

Actually, this error is from an old express boilerplate bug, where it didn't account for the fact that .listen() is an asynchronous action. This bug was fixed in v2.5.9 so it shouldn't be an issue anymore. Anyways, the "right" way to do it looks something like:

app.listen(process.env.PORT || 8080, function (err) {
  if (err) {
    throw err; // For completeness's sake.
  }

  // Now "app.address" should exist so this will work
  console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
});

The other way, it's a race condition and it just happens that .listen loses the race on the production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment