I followed the instructions here http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs_express.html and it works fine if I use the aws examples.
But when I tried it by myself, the basic Express skeleton, expected to give an output of "Express \n Welcome to Express", isn't working and is giving a 502 Bad Gateway error.
I noticed that my build is with Express 4.2 whereas the aws examples use Express 3.x.
From the beanstalk logs:
2014/06/28 03:41:57 [error] 1930#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xx.xxx.xx, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8081/", host: "my-env-xxxxxxxxxn.elasticbeanstalk.com"
There is no database, and no code changed from the skeleton generated by express.
(And btw, it works just fine if I do a npm start
locally on my mac)
Please help.
Update: The solution mentioned in the link below answer works in this case.
502 Bad Gateway Deploying Express Generator Template on Elastic Beanstalk
Though it is not clear to me exactly why AWS would execute in that order.