By jbopko
First time setting up a droplet with digital ocean. I have an ubuntu slice running. I can ssh and sftp. I have nodejs installed and running a server process on port 8000. I can’t seem to hit it from the browser. Any ideas?
sudo ufw status Status:inactive
no firewall running according to my DO management console
please help
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!
Heya,
Verify the Node.js Server is Running:
Ensure your Node.js server is up and listening on the correct port:
8000
:sudo netstat -tuln | grep 8000
You should see something like:
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN
Test locally from the droplet:
curl http://localhost:8000
If you get a response, the server is running correctly.
Your Node.js server may be bound to localhost
(127.0.0.1) instead of 0.0.0.0
, meaning it’s only accessible locally.
app.listen(8000, 'localhost');
Change 'localhost'
to '0.0.0.0'
Restart the Node.js process
Hey there!
If you want to access the Node.js app directly on the port itself, you need to make sure your Node.js process is listening on 0.0.0.0
and not just localhost
(127.0.0.1
). If it’s bound to localhost
, it won’t be accessible externally.
Open your Node.js app and check the server code. It should look something like this:
const http = require('http');
const server = http.createServer((req, res) => {
res.end('Hello, world!');
});
server.listen(8000, '0.0.0.0', () => {
console.log('Server is running on port 8000');
});
If it’s using 127.0.0.1
or not specifying the host, update it to 0.0.0.0
.
To verify if this is the case run this command to check if your Node.js app is running and listening on port 8000
:
sudo netstat -tuln | grep 8000
You should see something like this:
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN
If it’s not running, double-check your app and logs to ensure it’s starting correctly.
For a robust and secure setup, follow this guide from DigitalOcean instead: 👉 How To Set Up a Node.js Application for Production on Ubuntu 20.04
This guide will walk you through:
pm2
to keep it running in the background.80
to your Node.js app.Here’s a quick example of an Nginx config to proxy your Node.js app:
server {
listen 80;
server_name your_domain_or_ip;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
After setting this up, restart Nginx:
sudo systemctl restart nginx
Let me know how it goes!
- Bobby
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.