I have a NodeJS/Express/Jade app that works fine in my local Linux environment (Ubuntu 12.04 Desktop running NodeJS, talking to Ubuntu 12.04 Server running Couchbase). I have attempted to manually deploy the NodeJS app to a fresh Ubuntu 12.04 Server AMI on EC2. My Security Groups are set. The VM firewalls are set and the ports tested. The NodeJS VM can talk to the Couchbase VM (proven by console logs during startup). Both VMs are accessible via their Elastic IPs. For a simple NodeJS "Hello World" server on port 8000, it works fine. The main app, on port 3000, has issues.
1) The layout.jade, links to stylesheets and images log 500 errors when I call the app from outside EC2, but from another EC2 instance (the Couchbase VM) I can curl for an image and receive the file, seeming to indicate that site path settings are OK. Also, in that case, the expected 200 result code is logged by NodeJS.
2) The NodeJS logs Error: Error while establishing TCP connection. This occurs even if I am just asking for a single image file from the other EC2 VM.
Amazon support also says that the instance has logged occasional spikes to 100% CPU usage and that above approx 96% will cause the instance to lose network connectivity. However, I have been unable to cause a CPU spike by calling my app, or asking for an image file from the server, yet the TCP error is still logged.
Any suggestions of things to try will be greatly appreciated.
UPDATE: I still have the same problem, but I have eliminated my configuration of the Ubuntu 12.04 Server 64-bit AMI from the list of suspects by deploying the same app to the Bitnami 64-bit Ubuntu Node AMI (including the installation of Couchbase SDK+dependencies). The same issue crops up on the Bitnami-based instance. So, the problem apparently has to do with the app's ability to recognize its own resources.... which is still odd, because I can request those same resources (images, css files) and receive them fine, so Express is seeing them. And still I get the TCP connection error I can't explain in the log.
Here is the layout.jade that is getting all the 500s in AWS, but works fine on local Linux:
doctype html
html
head
meta(charset='utf-8')
meta(name='viewport', content='width=device-width, initial-scale=1.0')
title= title
link(rel="stylesheet", href="/stylesheets/pure-min.css")
link(rel="stylesheet", href="/stylesheets/grids-responsive-min.css")
link(rel='stylesheet', href='/stylesheets/layouts/marketing.css')
link(rel='stylesheet', href='/stylesheets/layouts/pure-skin-mmc.css')
link(rel='stylesheet', href='/stylesheets/style.css')
link(rel='stylesheet', href='/stylesheets/jquery.datepick.css')
link(href='http://fonts.googleapis.com/css?family=Nunito:400,700,300', rel='stylesheet', type='text/css')
link(rel="icon", href="/images/m.png", type="favicon")
script(type='text/javascript', src='/javascripts/jquery-1.10.2.min.js')
script(type='text/javascript', src='/javascripts/jquery.validate.js')
script(type='text/javascript', src='/javascripts/jquery.plugin.js')
script(type='text/javascript', src='/javascripts/jquery.datepick.js')
script(type='text/javascript', src='/javascripts/d3.min.js')
script(type='text/javascript', src='/javascripts/mmc.js')
body(class="yui3-skin-mmc pure-skin-mmc")
block content
UPDATE 2: I have been able to replicate this behavior locally by pointing to the EC2 Couchbase server instance. Apparently, although connecting to Couchbase causes no error, talking to it seems to be a problem, and once it errors, the app doesn't work. It may be that this is not the fault of app components, but rather due to issues with AWS configuration.