Google cloud instance not accessible by External IP

Viewed 1838

I have a Google Cloud VM instance which is basically created by a marketplace service 'Elasticsearch Certified by Bitnami'. I cannot access it publically via External IP. I allowed HTTP and HTTPS traffic from the firewall as well.

I can connect it via ssh but not from HTTP. After some research, I came to know that my instance is only accessible from the localhost(127.0.0.1) but I could not figure out how can I make it to be accessed publically.

I ran the netstat -antup command and the following is the result. From which I came to know about the localhost(127.0.0.1) only:

Result of netstat -antup command

I have another instance that is working fine. I can access that via HTTP but not this one, don't know why.

The instance that is working fine, I compared it with this and the only difference that I could figure out is that the correct instance is listening to port 9200 allowed for all. Screenshot below:

Correct index ports listening

PS: My application is running on port 9200(I can access via ssh login and able to run curl from the server itself)

I created a Firewall Rule to enable port 9200 for all. Which is below:

Firewall Rule for 9200 port

Following are the Firewall Rules that are applicable to my instance:

Firewall Rules

I checked all the similar questions here as well but not been able to resolve this. Any help would be appreciated. If need more information regarding this, I will provide that.

Thanks in advance.

2 Answers

ssh is port 22. If you want to access through http and https you have to allow ports 80 and 443 (tcp)

Note that 127.0.0.1 is not your external IP address, you will have to reserve a static external ip

Also if your instance has been restarted then a new ephemeral ip is assigned:

Ephemeral external IP addresses remain attached to a VM instance only until the VM is stopped and restarted or the instance is terminated. If an instance is stopped, any ephemeral external IP addresses that were assigned to the instance are released back into the general Compute Engine pool and become available for use by other projects. When a stopped instance is started again, a new ephemeral external IP address is assigned to the instance.

So in order to access VMs using external IP, you need to have following

  1. External IP attached to your virtual machine, It can be ephemeral or Static IP. Like Below

Compute engine virtual machine

You can attach an external IP to the VM by selecting the IP as highlighted in the screenshot below

enter image description here

  1. Assuming the application is already running locally on 9023 port in this VM, you need to allow tcp traffic on port 9023 in the firewall rule to the destination VM. After allowing the traffic in the rules, it will look like below -

tcp:9023 highlighted in the picture

and then you should be able to access http://<externalIP>:9023/ e.g. http://35.184.142.145:9023/

I just did this for nginx server running on port 9023, same can be done for any application running on any port.

Related