Question

My server only works on localhost but not works on ip address.

Posted January 9, 2021 262 views
NginxNetworkingUbuntu 20.04DigitalOcean Droplets

Hello, I’m using ubuntu 20.04 droplet. I’ve seen many tutorials that talked me that I don’t need many things to see my app run on the internet. They said that just run “pm2 start appname” and then I can see my website on the internet by send my browser to “serveripaddress(ipv4):portnumber”. In video, that works. But not for me.

When I try “curl http://localhost:port_number” or “curl http://127.0.0.1:port_number” in server connected bash, it works. But when I try to connect by ip address outside of server computer(or bash) the browser load page endlessly. I can’t get any logs both in digitalocean graph and pm2, about my attempt using ip address.

It happens even before I install nginx to server. I’ve heard that after install nginx, i can default nginx html when I get to my server ip address, but that also does not work.

Why does this happens? I can’t get where does this problem comes from. Because I use ipv6? Or because I set firewall which is in doc “Recommended Initial Droplet Configuration” (https://www.digitalocean.com/docs/droplets/tutorials/recommended-setup/)?
And how can I solve that?

“netstat -plant | grep portnumber” gives me this.
tcp6 0 0 :::port
number :::* LISTEN PID/node

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.

×
1 answer

Hi @pajaritomoyqi,

My first assumption would be the firewall. Try to allow incoming traffick to the port you are using on your application.

Additionally, set an IPv4 address as well and see if it would start working as well.

If it doesn’t work even after the above have been done, let me know I’ll try to dig around more!

Regards,
KFSys

Submit an Answer