title: cannot get nodejs working on amazon ec2 instance
body: <p>I am trying to run nodejs server on amazon micro instance for the past 3-4 days with no success.</p>
  
  <p>i followed so many tutorials and i cannot make the server work (so when its visited in browser or curl in powerShell and see the simple hello world).</p>
  
  <p>Here are the last 3 tutorials I've tried:</p>
  
  <p><a href="http://iconof.com/blog/how-to-install-setup-node-js-on-amazon-aws-ec2-complete-guide/" rel="noreferrer">http://iconof.com/blog/how-to-install-setup-node-js-on-amazon-aws-ec2-complete-guide/</a>
  <a href="http://techprd.com/setup-node-js-web-server-on-amazon-ec2/" rel="noreferrer">http://techprd.com/setup-node-js-web-server-on-amazon-ec2/</a>
  <a href="http://devblog.daniel.gs/2014/01/deploying-node-apps-on-aws-ec2-with.html" rel="noreferrer">http://devblog.daniel.gs/2014/01/deploying-node-apps-on-aws-ec2-with.html</a></p>
  
  <p>I've tried ubuntu/ amazon linux.</p>
  
  <p>I've also followed <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html" rel="noreferrer">http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html</a> just to see how the general process works and it did work fine.</p>
  
  <p>I get to the point where i do something like: <code>sudo node filename.js</code>
  and the server runs.</p>
  
  <p>However when i try visiting or curl it. it doesnt work. when i ping it it pings fine.</p>
  
  <p>in amazon i set the security group to basically allow everything like so:</p>
  
  <p><img src="https://i.stack.imgur.com/KYMhY.jpg" alt="enter image description here"></p>
  
  <p>in linux its self i followed : <a href="https://help.ubuntu.com/community/IptablesHowTo?action=show&amp;redirect=Iptables" rel="noreferrer">https://help.ubuntu.com/community/IptablesHowTo?action=show&amp;redirect=Iptables</a> to open the port i was trying to listen to and nothing. </p>
  
  <p>when i type : <code>sudo service iptables status</code> i get : </p>
  
  <p><code>1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpts:1337:1347</code></p>
  
  <p><code>2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpts:1338:1348</code></p>
  
  <p><code>3 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:10000</code></p>
  
  <p>keep in mind i am not a server savvy guy.</p>
  
  <p>Any help would be highly appreciated.</p>
  
  <p><strong>UPDATE:</strong> To start my node server i use the basic code found in nodejs.org :</p>
  
  <pre><code>var http = require('http');
  http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');
  }).listen(1337, '127.0.0.1');
  console.log('Server running at http://127.0.0.1:1337/');
  </code></pre>
  
  <p>This is exactly how my file look like</p>