29

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:

enter image description here

YanetP1988
  • 1,346
  • 3
  • 18
  • 43
Coder1000
  • 4,071
  • 9
  • 35
  • 84
  • 1
    Can you SSH in your server and verify that a service is listening on port 8080? i.e. netstat --listen I would also check that your server is using the tag “http-server”. You can run [“gcloud compute instances describe”](https://cloud.google.com/sdk/gcloud/reference/compute/instances/describe) – Carlos Feb 13 '17 at 23:40
  • 1
    @Carlos It does not seem to listen for port 8080. At least "8080" does not appear anywhere in the output of the command netstat --listen – Coder1000 Feb 14 '17 at 12:16
  • Ok, at least we know the service is down. Did you get any errors in the serial console? Does it show the startup script run successfully and installed the applications? – Carlos Feb 14 '17 at 21:38
  • @Carlos There is a LOT of data in the logs, but couldn't see any error. The startup script seems to have been run without issues. If you have an email address, I can send you the logs. – Coder1000 Feb 15 '17 at 10:48
  • I am following the tutorial, but at the moment I am getting some errors running "npm Install". So no luck yet running it locally. I will post any updates. – Carlos Feb 15 '17 at 21:31
  • @Carlos Great, thx ! – Coder1000 Feb 15 '17 at 22:35
  • 1
    Did this command "gcloud compute instances get-serial-port-output my-app-instance --zone us-central1-f" return the success as discussed in the tutorial (i.e.: "Finished running startup script")? – Newteq Developer Feb 16 '17 at 13:18
  • @Sanity1123 It did. – Coder1000 Feb 16 '17 at 13:55
  • Not sure then, I think that would be the only thing that would cause you to get the error that you are getting. And when you ran it locally, downloading the node packages and running localhost:8080 - did that work too? – Newteq Developer Feb 17 '17 at 07:42
  • @Sanity1123 Of course. – Coder1000 Feb 17 '17 at 10:59
  • You might have to contact google cloud support for assistance then. Reading through the tutorial it seems like everything should work if followed correctly - and in your case, this is the case. – Newteq Developer Feb 17 '17 at 11:55
  • @Sanity1123 I have been in contact with the Google Cloud Support sine I created this question. – Coder1000 Feb 17 '17 at 17:46
  • There is a request to review the document. There are some errors while trying to even run the example locally. – Carlos Feb 21 '17 at 00:05
  • 3
    @Coder1000 Were you able to resolve this problem? If so, please provide the resolution as a self-answer which will also help the community having similar issue. – Faizan Aug 28 '17 at 20:02
  • What IP did you try to connect to? Make sure that it is an external IP. Check it out in your GCP console at `VPC network > External IP addresses` to see if you have associated an external IP address with your instance. – momocow May 03 '18 at 10:10
  • Also make sure your instance has been tagged as `http-server`. – momocow May 03 '18 at 10:11
  • Try restarting the httpd and see the lof files of httpd for help. – Kanishk Kumar Gupta Jun 18 '18 at 12:15
  • How about if you add your own ip to the ip range just to make sure the problem is not there. Otherwise, make sure your instance is connected to internet ! ((I don't know why it shouldn't but double check)) – Areza Jan 15 '19 at 22:21
  • 1
    Anyone an update on this one? I have EXACTLY the same issue and have done exactly the same. The docs are not good on this one. – WJA Jul 26 '19 at 15:53

4 Answers4

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
howie
  • 2,587
  • 3
  • 27
  • 43
0

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

jackssrt
  • 364
  • 1
  • 2
  • 16
Jehy
  • 4,729
  • 1
  • 38
  • 55
0

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"
zizizach
  • 26
  • 2
0

First, check if the firewall settings are correct as the others had mentioned.

Second, I was having the same problem and solve it by selecting on the Network Service Tier section the "Standard" option instead of the "Premium" one.

Third, check if there is another application running on the same port using the command:

netstat -tulpn

Which should return something like:

(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp6       0      0 :::80                   :::*                    LISTEN      -

In my case it was not working because I had two applications running on the same port.