The Problem:

I just tried to install Jenkins on VM on Google Cloud. Jenkins by default runs on port 8080. So I tried accessing Jenkins from public IP at port 8080 but it says the site cant be reached.

My first thought was to check if the service is up and running so checked with command-line utility “netstat” to check the network connects. It looks like the Jenkins is up and running and port 8080 yet I am not able to access it through public IP.

The Solution:

We are trying to access the the public through 8080 from the internet, in Google Compute Engine by default all incoming ports from external IPs in GCE are blocked. So we need to create firewall rule that allows INGRESS tcp:8080.

Create a new firewall rule

Add the newly created network tag to your VM and save.

Add the network tag to you VM

Go to the browser and try to access the public IPwith port number. You should be able to access the service now.

or you could do it through gcloud command

# Create a new firewall rule that allows INGRESS tcp:8081 with VMs containing tag 'allow-tcp-8081'
gcloud compute firewall-rules create rule-allow-tcp-8081 --source-ranges --target-tags allow-tcp-8081 --allow tcp:8081

# Add the 'allow-tcp-8081' tag to a VM named VM_NAME
gcloud compute instances add-tags VM_NAME --tags allow-tcp-8081

# If you want to list all the GCE firewall rules
gcloud compute firewall-rules list

Learner, thinker and Doer.