Cannot connect to localhost port 80 in GCP Compute Engine VM

googlegoogle-cloud-platformgoogle-compute-enginenetworking

I have setup a Windows Server 2019 with Containers Compute Engine VM in Google Cloud. I have installed IIS. I want to go to the following URL on the local server in a browser, or via wget: http://localhost. However, I am getting back a connection refused. I tried on the Private IP and Public IP from the machine, both failed. Also fails from outside the VM using public IP.

I check with netstat and port 80 is open, and IIS is running. I ran Test-NetConnection and got the following result:

Test-NetConnection -Port 80 -ComputerName 127.0.0.1 -InformationLevel Detailed


ComputerName            : 127.0.0.1
RemoteAddress           : 127.0.0.1
RemotePort              : 80
NameResolutionResults   : 127.0.0.1
MatchingIPsecRules      :
NetworkIsolationContext : Loopback
IsAdmin                 : False
InterfaceAlias          : Loopback Pseudo-Interface 1
SourceAddress           : 127.0.0.1
NetRoute (NextHop)      : 0.0.0.0
TcpTestSucceeded        : True

So apparently the port is open but I just can't retrieve data from it.

This is super weird because it is on localhost. I also went into the VPC Network and added an HTTP Ingress (port 80) rule for 0.0.0.0/0.

I really can't figure this out. Why would I not be able to connect to a running port 80 web server on my own machine? Is there some extra firewall in this GCP image somewhere?

Any help would be greatly appreciated.

Update: I tried both localhost and 127.0.0.1 and neither work

Best Answer

Turns out the application was redirection to https by default, and the certificate was not configured, causing an error

Related Topic