3

I have a Dash application that I can run locally and view in my browser. I have moved it to Google Cloud Compute Engine and the app runs, but I can't see it in my browser at the 127.0.0.1 address where it's running. I have tried to allow http and https traffic to the virtual machine using gcloud compute firewall-rules create FIREWALL_RULE --allow tcp:80,tcp:443 in the console without any luck. How can I view it in my browser?

Serhii Rohoza
  • 4,287
  • 2
  • 16
  • 29
sh4399
  • 43
  • 4

1 Answers1

2

You were able to reach http://127.0.0.1 and/or https://127.0.0.1 when you run it locally because you run your web browser on the same computer. More information you can find here:

The local loopback mechanism may be used to run a network service on a host without requiring a physical network interface, or without making the service accessible from the networks the computer may be connected to. For example, a locally installed website may be accessed from a Web browser by the URL http://localhost to display its home page.

The name localhost normally resolves to the IPv4 loopback address 127.0.0.1, and to the IPv6 loopback address ::1.

As result, you can access IP 127.0.0.1 located on your VM instance only from your VM instance.

To check your application on IP 127.0.0.1 you can use command curl from command line of your VM instance:

instance:~$ curl -I http://127.0.0.1
instance:~$ curl -I https://127.0.0.1

To allow access to your application via ports 80/443 you should go to Compute Engine -> VM instances -> click on NAME_OF_YOUR_VM_INSTANCE-> click on EDIT -> go to Firewalls and select Allow HTTP traffic and Allow HTTP traffic -> click Save. Have a look at the documentation Firewall rules overview and Configuring network tags to find more details.

To access your application from web browser you should use external IP address that you can find at Compute Engine -> VM instances -> look for NAME_OF_YOUR_VM_INSTANCE and External IP:

http://EXTENAL_IP_OF_YOUR_VM_INSTANCE
https://EXTENAL_IP_OF_YOUR_VM_INSTANCE
Serhii Rohoza
  • 4,287
  • 2
  • 16
  • 29
  • 1
    Thanks for the response. After doing this I'm only seeing a default index page instead of the application when it's running. Do you know why this might be? Elsewhere I see that application files often tend to be stored in the `/var/www' directory and an index.html file is present but I have a single app.py file, do I need to to something different for this to show up? Or move it to a certain directory? (I tried moving it to the above mentioned location with no success). Thanks. – sh4399 Mar 11 '20 at 17:36
  • 1
    You should configure web server. Have a look at these examples https://stackoverflow.com/q/40498208/12428794, https://stackoverflow.com/a/27565361/12428794 and https://stackoverflow.com/a/26831634/12428794 (just replace localhost with external IP). If it's not solve your problem just post another question because it's a different field. – Serhii Rohoza Mar 11 '20 at 17:53