1
votes

I am unable to access some specific ports in a GCP instance I created. I spin up a simple python server using command python3 -m http.server <port#> on port 22221 and 22222. I can curl to both ports inside the machine or another machine inside the same VPC(using localhost or public ip). but when I tried to curl both ports from outside using public ip, only 22222 works, but the other port does not work.In the firewall I opened up all the ports.

My Firewall rule opened up all the ports Firewall-Screenshot

Curl inside the machine-Screenshot

netstat netstat-screenshot

update 1 : i did the same steps in AWS. Created an Ec2 -> assigned security group which allows all ports inbound/outbound -> spinup python simple http server on port 22222 and 22221. only 22222 is accessible from public ip address. Looks like it is specific to OS(I am using ubuntu). below is the nmap from inside and outside the instance.

nmap inside the instance

nmap from remote machine

2
Are you sure you're using the public ip when you make the request?Cristyan
yes.. i have started the server in 2 different ports and one port was accessible. i used same ip(public ip) in the curl requests.Suresh Sivanantham
@Alioua - added more info to Question. it may give more details.Suresh Sivanantham

2 Answers

1
votes

@Alioua - I figured it out. Your hint on nmap helped. It is the Firewall Issue set by my corporate network. I was testing all from a corporate network and some of the ports are blocked. I tried through my mobile LTE data and came to know it was working fine from the very beginning.

0
votes

It's the GCP firewall is not configured, the one shown it your screenshot, it's just to allow internal traffic in the your network (you notice that the source IP is 10.128.0.0/9), you have to add a new firewall rule to allow external traffic (you can set the source IP (0.0.0.0/0) if you want to let external traffic from any IP or you can specify a CIDR)