I am trying to run nodejs server on amazon micro instance for the past 3-4 days with no success.
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).
Here are the last 3 tutorials I've tried:
http://iconof.com/blog/how-to-install-setup-node-js-on-amazon-aws-ec2-complete-guide/ http://techprd.com/setup-node-js-web-server-on-amazon-ec2/ http://devblog.daniel.gs/2014/01/deploying-node-apps-on-aws-ec2-with.html
I've tried ubuntu/ amazon linux.
I've also followed http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html just to see how the general process works and it did work fine.
I get to the point where i do something like: sudo node filename.js
and the server runs.
However when i try visiting or curl it. it doesnt work. when i ping it it pings fine.
in amazon i set the security group to basically allow everything like so:
in linux its self i followed : https://help.ubuntu.com/community/IptablesHowTo?action=show&redirect=Iptables to open the port i was trying to listen to and nothing.
when i type : sudo service iptables status
i get :
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpts:1337:1347
2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpts:1338:1348
3 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:10000
keep in mind i am not a server savvy guy.
Any help would be highly appreciated.
UPDATE: To start my node server i use the basic code found in nodejs.org :
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/');
This is exactly how my file look like
You haven't provided enough info, but I'll try and outline the general troubleshooting techniques.
Is your node program running and serving requests? Get on the Ec2 box and do curl -v localhost:8000
(or whatever your node port is.) It should spit out your app. If not, your node.js setup isn't right.
Is your nginx running? Get on the box and type curl -v localhost
. That will look on your port 80. If it doesn't proxy to your app, it's probably an nginx configuration problem.
Can you reach the box via IP address? From your desktop/laptop, do curl -v x.x.x.x
where x.x.x.x
is your EC2 Public IP address. If that hangs, there is a firewall problem.
Can you reach the box via your DNS? (Assuming you are trying to have foo.com point to it) Try curl -v http://foo.com/
. If that doesn't work, your DNS may not be correct.
However when i try visiting or curl it. it doesnt work.
Please be more specific.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With