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, ‘127.0.0.1’); console.log(‘Server running at http://127.0.0.1:1337/’);
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?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Update, I’m using IP address “0.0.0.0” in the node app, and netstat shows ip and port number. Still no success =/
Update** <br>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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.