Everyone come across this issue in day to day job.There could be multiple reason for this issue .”Unable to ssh/ping to my ec2 instance ” .First you need to look out what kind of error message you are getting . If you read the error message carefully we can shortout easily . Otherwise we have to check all the possible reason.
Error connecting to your instance: Connection timed out
Before checking all the below steps first verify the instance health check 2/2 passed and the instance is in :running ” state.
Security Group
*Check your security group rules. You need a security group rule that allows inbound traffic from your public IPv4 address on the proper port.
*For Linux instances: Verify that there is a rule that allows traffic from your computer to port 22 (SSH)
*For Windows instances: Verify that there is a rule that allows traffic from your computer to port 3389 (RDP).
*If your security group has a rule that allows inbound traffic from a single IP address , Check if the static IP is correct and exists.
EC2-VPC
*Verify internet Gateway is attached to your VPC
*Check the route table for the subnet. You need a route that sends all traffic destined outside the VPC to the Internet gateway for the VPC.
*On the Route Table tab, verify that there is a route with 0.0.0.0/0
as the destination and the Internet gateway for your VPC as the target.
*Check the network access control list (ACL) for the subnet. The network ACLs must allow inbound and outbound traffic from your local IP address on the proper port. The default network ACL allows all inbound and outbound traffic
*Check that your instance has a public IPv4 address. If not, you can associate an Elastic IP address with your instance
Common
*Check the internal firewall allows inbound and outbound traffic /port from your computer or office network
*Check the CPU load on your instance; the server may be overloaded , You can view from AWS Console Monitoring field and in cloudwatch also.
*Check the instance log and instance screen shot from AWS Console Instance-Actions page