mercredi 25 février 2015

ExpressJS - Elastic Beanstalk 502 Bad Gateway

I am running a Express.js app on Amazon Elastic Beanstalk and my environment was successfully created, but when I go to my environment via the URL Amazon has created, I receive a 502 Bad Gateway nginx/1.6.2 error. While I have read other resources on StackOverflow, which suggest I rename my main file from server.js to main.js and set the port in a bin/www folder, I feel like this isn't the solution for my app. I ran node server.js, which is the command I believe Elastic Beanstalk runs and it doesn't work, (error message):



node server.js
events.js:72
throw er; // Unhandled 'error' event
^
Error: failed to connect to [undefined:27017]


because I have ENV variables set up in a .env file, so the only way I can run my server is with foreman. This has made me think that the 502 error is the result of Elastic Beanstalk not being able to comprehend the variable and thus causing the server to fail. Can anyone confirm that I am on the right path or is this issue really because my main file is named server.js and not in the bin/www folder?





Aucun commentaire:

Enregistrer un commentaire