I\'m very new with amazon web services, and I am trying to set up a node.js app on their elastic beanstalk. I set up the instance and uploaded/deployed the site, but while the h
I had a problem the same as - or very similar to this, and it was caused the fact that my code was listening to a custom port, instead of the one that Elastic Beanstalk sets as an environment variable (8081
).
I fixed this setting in the port near top of my app.js
or server.js
file, just after I create the express app. For example:
var app = express();
app.set('port', (process.env.PORT || 5000)); // 5000 was my original port
Then using this port in the app.listen
method instead of my own custom port number:
app.listen(app.get('port'), function () {
console.log('Server has started! http://localhost:' + app.get('port') + '/');
});
More details here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.container.html#nodejs-platform-proxy