I am trying to create a node.js application, whenever I am running it in my droplet system, using “node server.js” command, it is only working in the local machine, i.e’, visible when I use “curl http://localhost:5000” command, but is not available globally, like in my browser whenever I go and search for “139.59.36.43:5000” or “nanna.website:5000”, it returns a page with message “THIS SITE CAN’T BE REACHED”
//my very simple node app
var http = require(‘http’);
var server = http.createServer(function(req, res){ res.setHeader(‘Content-Type’,‘text/html’); res.end(‘<b>Hello Manna!</b>’); });
server.listen(5000,function(){ console.log(“server running”); });
The error message that I receive in the browser **This site can’t be reached
nanna.website took too long to respond. Try: Checking the connection Checking the proxy and the firewall ERR_CONNECTION_TIMED_OUT**
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!
It is probably a firewall issue, if you need security on your droplet then you must allow incoming connections to port 5000 on your droplet you can easily achieve this with this command:
sudo ufw allow 5000
If you do not need security you can just disable firewall with this command:
sudo ufw disable
Hope this helps.
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.