title: Error Deploying node js app to AWS Elastic Beanstalk
body: <p>I deployed node js application to AWS EBS. When I run the app, i get the error " 502 Bad Gateway " nginx/1.6.2 . This is what i found out in the log.</p>
  
  <p>env.elasticbeanstalk.com/"
  2015/04/21 10:52:01 [error] 3807#0: *86 connect() failed (111:      Connection refused) while connecting to upstream, client: 172.31.4.86, server: , request: "GET / HTTP/1.1", upstream: "<a href="http://127.0.0.1:8081/" rel="nofollow">http://127.0.0.1:8081/</a>", host: "clinicaltrials-env.elasticbeanstalk.com"</p>
  
  <p>This is my package.json file</p>
  
  <pre><code>{
  "name": "Clinical_Trial_Analytics",
  "version": "1.3.2",
  "private": true,
  "scripts": {
      "start": "node main.js"
    },
  "dependencies": {
      "express": "3.0.6",
      "stylus": "0.31.0",
      "jade": "0.27.7",
      "mongodb": "1.2.7",
      "moment" : "1.7.2",
      "emailjs": "0.3.3",
      "json2html": "1.0.0"
  },
  "engines": {
      "node": "0.12.0",
      "npm":  "1.1.65"
  }
  }
  </code></pre>
  
  <p>This is my main.js file</p>
  
  <pre><code>var express = require('express');
  var http = require('http');
  var app = express();
  
  app.configure(function(){
  app.set('port', process.env.PORT || 8080);
  app.set('views', __dirname + '/server/views');
  app.set('view engine', 'jade');
  app.locals.pretty = true;
  
  app.use(express.bodyParser());
  app.use(express.cookieParser());
  app.use(express.session({ secret: 'super-duper-secret-secret' }));
  app.use(express.methodOverride());
  app.use(require('stylus').middleware({ src: __dirname + '/client' }));
  app.use(express.static(__dirname + '/client'));
  });
  
  app.configure('development', function(){
  app.use(express.errorHandler());
  });
  
  require('./server/router')(app);
  
  http.createServer(app).listen(app.get('port'), function(){
  console.log("Clinical Trials server listening on port " +  app.get('port'));
  })
  </code></pre>
  
  <p>I am unable to figure out the issue. Is it with the node version or any other problem? Thanks in advance.</p>