Skip to main content

Posts

Showing posts from August, 2014

node.js and elastic beankstalk

AWS uses Nginx to proxy requests to node application. When you first deploy your app and try to load the site in a browser you may see an error - "502 Bad Gateway". To troubleshoot, you may want to check node.js logs. You could either go to elastic beanstalk dashboard to get a most recent snapshot of logs or ssh to an ec2 instance to view a log file at /var/log/nodejs/nodejs.log . In my case, I was getting an error - "Error: listen EADDRINUSE". I was starting a node server on 8080 but AWS was already running Nginx on the same port. (Note: To lookup ports in use type "sudo netstat -lnptu") . I noticed that a node process was running on port 8081. So I updated my node.js server to listen on port 8081 and that fixed the problem. I could then request the site (just using the dns name, no port required in the url since it is routed automatically to 8081 internally by Nginx). jfyi, when you use "git aws.push" to upload latest code to aws it is