Question

How to access localhost:3000 from local machine

Posted July 9, 2019 6.3k views
Applications Ubuntu 18.04

Hi,

I have a ruby app deployed on ubuntu droplet. The app is running on localhost:3000. How can I check from outside, like my local laptop to see the app is running properly?

thanks!

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

Hello,

Can you please run the following command and provide us with the output:

netstat -plant

I think that you might be just able to visit your.server.ip:3000

Let me know how it goes.

Regards,
Bobby

  • Here is the o/p:

    root@ubuntu-s-1vcpu-1gb-sfo2-01:/var/dev.to# netstat -plant
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

    tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 655/systemd-resolve
    tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 991/sshd

    tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 32442/postgres

    tcp 0 304 206.189.76.241:22 76.126.20.84:55265 ESTABLISHED 13896/sshd: root@pt
    tcp6 0 0 :::22 :::* LISTEN 991/sshd

    • Good job with the output. Based on that information, I do not see an app running on port 3000, localhost or otherwise. If you look at the lines you do provide, you can see an example of a localhost only app and an app that is publicly accessible (firewall notwithstanding):

      Localhost only, postgres:
      tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 32442/postgres

      The relevant info is the 127.0.0.1 which is the localhost IP address.

      Publicly accessible, sshd, so you can connect:

      tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 991/sshd
      

      The relevant info there is the IP address before the port :22, 0.0.0.0 - that means it is listening on all interfaces on your droplet, local and public.

      Try starting your app and running that command again - we should see a line that has :3000 and ruby in it. If it is bound to 127.0.0.1:3000 that is localhost only.

      At that point you can either change your app config to bind to your public IP (or all interfaces) or, and this is a common solution, you run a proxy in front of the app like nginx.

      Let us know how it goes and good luck!

Submit an Answer