Question

use nodejs API on port 6000

i setup a nodejs droplet. installed pm2 and copied the files to a folder with filezilla. also created a firewall to allow traffic on port 6000 and linked it to the droplet. ran the app with pm2 start app.js

note: this is my first time using digitalocean note: tried doing calls to my ipv4 address aswell as the floating one


Submit an answer

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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

By default node.js will listen only on localhost/127.0.0.1 for local requests. If you specify the IP address in your app as 0.0.0.0 it will listen on all IPs. Another option is to enter only the IP it will be used with (if using a floating IP this is the anchor IP, not the public floating IP users will use).

This shows an example that should listen publicly on port 6000 as long as there is not a firewall blocking it.

var http = require('http');

http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');
}).listen(6000, "0.0.0.0");
console.log('Server running at http://0.0.0.0:6000/');

digital ocean blocking by default port above :6000 , dont know the reason but , if you will run node less then 6000 then only its working fine for web and APK else only working on APK…