I span up a Node.js Droplet, cloned my git repo, and did an npm install then an npm start. I got the message:
http://[::1]:3000
http://[::1]:3000/ping
If I ping the droplet IP address (ping <dropletIPAddress>
) from the terminal, I get a response, but if I try to go to the <dropletIpAddress>:3000
, I get “This site can’t be reached”.
What could be wrong?
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.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Hi there,
What I would personally suggest is using Nginx as a reverse proxy so that you could also issue an SSL certificate, you can follow the steps on how to do that here:
Here is also a YouTube video on how to do the same:
Regarding your specific issue itself, this issue might be due to a few reasons. Here are some steps you can take to resolve the issue:
Listen on the correct IP address: In some cases, applications listen on localhost (
127.0.0.1
or[::1]
) by default and do not accept connections from other IP addresses. To solve this, in your application, when starting the server, instead of.listen(3000)
, use.listen(3000, '0.0.0.0')
. This tells your application to listen on all available network interfaces.Firewall: Your firewall may be blocking incoming connections to port 3000. If you’re on a Linux server, you can use
iptables
orufw
to allow incoming connections. Withufw
, the command would besudo ufw allow 3000
. If you’re using DigitalOcean’s firewall service, you’ll need to add a rule to allow incoming traffic on port 3000.Ensure your application is running: Make sure that your application is still running. Node.js applications will stop if there’s an uncaught exception, or if they are manually stopped. You can use tools like
pm2
,forever
ornodemon
to make sure your application restarts if it crashes.Check server logs: If none of the above works, you should check the logs for your application and your server. They may provide more information on why connections are failing.
Check if the Node.js application is successfully starting: If there’s a problem with the application code, the Node.js process may be crashing on startup. Use
npm start
and check the console for any error messages.Remember to replace
3000
with the actual port your Node.js application is running on if it’s different.Best,
Bobby