Compute Engine : “This site can’t be reached”

2019-06-14 22:38发布

问题:

SITUATION:

I am following this tutorial.

When I get to the part where I create an instance and I execute the necessary commands, I get to the following:

To see the application running, go to http://[YOUR_INSTANCE_IP]:8080,

where [YOUR_INSTANCE_IP] is the external IP address of your instance.

PROBLEM:

The page deosn't load. I get the following error message:

This site can’t be reached

QUESTION:

What could have gone wrong ?

All previous steps worked perfectly and I was able to access my website locally.

I waited for the Compute Engine instance to be ready by checking:

gcloud compute instances get-serial-port-output my-app-instance --zone us-central1-f 

and although I reproduced all the steps twice, I am still met with the error message.

Something must be missing.


EDIT:

My firewall rules:

回答1:

If your code and firewall rules are correct then it's highly possible that you are trying to connect to wrong IP. You should be using external IP, not internal one which you get using ifconfig, you can get your external IP at whatsmyip.com



回答2:

I guess you don't apply firewall tag to instance ?

First, you can check your compute instences tags.

gcloud compute instances describe my-app-instance

In your example , you should see http-server in tags-items, like follows

tags:
  fingerprint: xxxxxxx
  items:
  - http-server
  - https-server

If not exist, you should add the tags to an existing VM instance, use this gcloud command:

gcloud compute instances add-tags [YOUR_INSTANCE_NAME] --tags http-server,https-server

To add the tags at the time of the instance creation, include that flag in your statement:

gcloud compute instances create [YOUR_INSTANCE_NAME] --tags http-server,https-server