Question

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

Posted January 9, 2021 4k 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

1 comment
  • I am having the Same problem, not able to access apache, nodejs and other server from outside world by can access from localhost. Please tell the complete solution fast. I am using your ubuntu server, and I facing big problem in this.

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.

×
Submit an Answer
3 answers

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

  • actually im having the same exact issue, ive checked the firewall, all is ALLOW, ive checked the ip addr made sure everything is correct. ive even reinstalled nginx nothing has worked so far and all the tutorials and walk-throughs Ive found get up to a certain point and cant move forward because commands don’t work due to versions of software and or os version or my hardware was different. i have a poweredge t40 new system server tower, with ubuntu 20.04 desktop version, nginx/1.18.0

    ive been asking around and no one seems to have an answer. my docs are set up properly, my domain is through ionos.com the system is able to notice it and location and registration. but even with all that the server ip still wont run i used the curl -4 icanhazip.com command to retrieve it, but my local or my ipv4 on the computer doesnt match the curl-ip starts with 75 where my ipv4 starts with 192, im not sure how to set the ipv4 this is all relatively new to me. please let me know what i can do to solve this issue. thank you

  • I am having the Same problem, not able to access apache, nodejs and other server from outside world by can access from localhost. Please tell the complete solution fast. I am using your ubuntu server, and I facing big problem in this.

Hi @ecrout,

Can I ask you to provide us with your Nginx configuration file for your domain or default configuration file to see if there is anything that is out of order inside of it?

  • I am having the Same problem, not able to access apache, nodejs and other server from outside world by can access from localhost. Please tell the complete solution fast. I am using your ubuntu server, and I facing big problem in this.

I am having the Same problem, not able to access apache, nodejs and other server from outside world by can access from localhost. Please tell the complete solution fast. I am using your ubuntu server, and I facing big problem in this.

  • Hi @namankasera1,

    To help you with the issue, please do provide me with the following information:

    • Apache Configuration
    • How are you proxying from ports 80 and 443 to your NodeJS configuration
    • Your Firewall Rules.

    Looking forward to your reply!