Why doesn't "http://my_ip_address:port" work on my droplet?

April 13, 2014 1.1k views
Hi, I created a simple http node app for testing, but I can't get it to work on my droplet. The code is the sample code from 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, ''); console.log('Server running at'); The node app runs, but when I hit "http://my_ip_address:1337" I get no result. I have a domain name connected to my droplet, and are wondering if that is the reason I can't connect. I tested this on a fresh droplet aswell, and its working as expected. PS: If i listen on port 80 instead, in the node app, it works. Why can't I use any other ports, any suggestions?
3 Answers
Update, I'm using IP address "" in the node app, and netstat shows ip and port number. Still no success =/
Answer: I was trying to set this up on a droplet created from the pre-made Ghost image by DO. Finally figured out that this image comes with some rules already applied to IPTABLES. That was the reason I couldn't reach my node app on a random port number. Added a rule to IPTABLES, and everything is working as expected.
Great! Glad to hear you got it working.
Have another answer? Share your knowledge.