Can't connect to EC2 instance in VPC (Amazon AWS)
Solution 1:
To communicate outside of the VPC, each non-default subnet needs a routing table and an internet gateway associated to it (the default subnets get an external gateway and a routing table by default).
Depending on the way you have created public subnet in the VPC, you might need to explicitly add them additionally. Your VPC setup sounds like it matches Scenario 1 - a private cloud (VPC) with a single public subnet, and an Internet gateway to enable communication over the Internet from the AWS VPC documentation.
You will need to add an internet gateway to your VPC and inside the Public subnet's routing table assign 0.0.0.0/0
(default route) to go to the assigned internet gateway. There is a nice illustration of the exact network topology inside the documentation.
Also, for more information, you can check the VPC Internet Gateway AWS documentation. Unfortunately it's a little messy and a non-obvious gotcha.
For more details about connection issues, see also: Troubleshooting Connecting to Your Instance.
Solution 2:
Not sure if this is exactly this case but I just created a VPC with Public and Private Subnets and noticed that there is a default security group that has the source address as the same security group name. Effective it has no access. Had to change this source to Anywhere and it started working.
Solution 3:
I've noticed that (I think) you need to be careful about which availability zone your instance is created in. The SubNet, Network Interface and Instance need to be in the same availability zone otherwise there is no way to connect to a public IP for that instance.
I may be wrong - but I don't think so, this has cost me 12 hours of work to figure out.
Hope this helps someone else.