0

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.

Community
  • 1
  • 1
Kaya Toast
  • 5,267
  • 8
  • 35
  • 59
  • have you uncommented the line ` // app.use(express.static(path.join(__dirname, 'public')));` – Kamrul Jun 28 '14 at 05:11
  • 1
    no, as the docs do not state it as necessary to test it (end of step 5). but since you suggested it, i tried. no change in the result. – Kaya Toast Jun 28 '14 at 05:30
  • The document says -- "On your local computer, comment out the static mapping in `node-express/app.js`. This step is not required, but it is a good test to see if the static mappings are configured correctly. `// app.use(express.static(path.join(__dirname, 'public')));`" – Kamrul Jun 28 '14 at 05:32
  • That is mentioned in step 6. It should work at the end of step 5 itself. ... in any case, I've commented it, and it is not working. – Kaya Toast Jun 28 '14 at 05:38
  • I have just now downloaded the code form (http://elasticbeanstalk-samples-us-east-1.s3.amazonaws.com/nodejs-example-express.zip). by default line is uncommented which is fine. then put development database info (i.e., host, user, port, password). then go to the folder run `npm install`. then `node app.js`. then on browser `localhost:3000` is working. – Kamrul Jun 28 '14 at 05:48
  • Thank you for taking the trouble to do that. But that is not the problem I'm trying to solve. The downloaded code works for me too. The thing is if I start from scratch, without the db, but with simply Express 4, it doesn't work. I would like to start off with Express 4. – Kaya Toast Jun 28 '14 at 05:50
  • ooh right. sorry missed your point totally. – Kamrul Jun 28 '14 at 05:52
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/56451/discussion-between-kamrul-and-kaya-toast). – Kamrul Jun 28 '14 at 06:06

0 Answers0