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

天涯浪子 提交于 2019-12-23 06:47:07

问题


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:


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



回答2:


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




回答3:


I will suggest looking into this step:

gcloud compute instances create my-app-instance \
--image-family=debian-9 \
--image-project=debian-cloud \
--machine-type=g1-small \
--scopes userinfo-email,cloud-platform \
--metadata app-location=$BOOKSHELF_DEPLOY_LOCATION \
--metadata-from-file startup-script=gce/startup-script.sh \
--zone us-central1-f \
--tags http-server

Please ensure the instance is created with the http-server tag

Otherwise, the firewall rules will not take effect on your instance

gcloud compute firewall-rules create default-allow-http-8080 \
--allow tcp:8080 \
--source-ranges 0.0.0.0/0 \
--target-tags http-server \
--description "Allow port 8080 access to http-server"


来源:https://stackoverflow.com/questions/42098008/compute-engine-this-site-can-t-be-reached

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!