1

I'm trying to deploy a basic restify node app to AWS EB but when I do I get a 502 Bad Gateway error. The AWS console also shows that the application is in Health: Severe. It seems as though it isn't correctly serving via port 80. Here is my server.js:

var restify = require('restify');
var server = restify.createServer();

server.get('/', function(req, res) {
    res.send("Hello");
    return next();
});

var port = process.env.PORT || 3000;
server.listen(port);
2
  • 1
    What do the logs on your EC2 instance(s) say? look in /var/log/nodejs/nodejs.log
    – Clarkie
    May 1, 2016 at 16:45
  • Hhhhhhmmmm, it's probably not the source of the issue, but one problem is you have no code to close down your server when it's done. I would suggest you probably want a response.end(); in there somewhere... May 1, 2016 at 17:06

1 Answer 1

0

Seems as though on EB that nginx redirects to node on port 8081, so I changed to that.

Additionally for whatever reason the node instance wasn't being run after "eb deploy". I added "node server.js" in software configuration on aws and now it seems to work fine.

1
  • 1
    You can use process.env.PORT, so that you don't hardcode 8081 May 3, 2016 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.