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!
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.
Heya,
Verify the Node.js Server is Running:
Ensure your Node.js server is up and listening on the correct port:
8000
:You should see something like:
Test locally from the droplet:
If you get a response, the server is running correctly.
Check Node.js Binding
Your Node.js server may be bound to
localhost
(127.0.0.1) instead of0.0.0.0
, meaning it’s only accessible locally.Change
'localhost'
to'0.0.0.0'
Restart the Node.js processHey 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 justlocalhost
(127.0.0.1
). If it’s bound tolocalhost
, it won’t be accessible externally.Open your Node.js app and check the server code. It should look something like this:
If it’s using
127.0.0.1
or not specifying the host, update it to0.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
:You should see something like this:
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:
After setting this up, restart Nginx:
Let me know how it goes!
- Bobby