EC2 SSH: Connection timed out
An EC2 SSH timeout is a network path problem. Check the security group, the subnet route to the internet gateway, the network ACL and the public IP.
What you see
Network error: Connection timed outError connecting to [instance], reason: -> Connection timed out: connect
What it means
A timeout means your packets never got an answer. That points to the network between you and the instance, not to your key or username. Work through the path in order: the security group, the subnet route, the network ACL, and whether the instance has a public address at all.
How to confirm the cause
- 1Confirm the instance is running and passed its status checks
aws ec2 describe-instance-status --instance-ids INSTANCE_ID
A new instance can take a few minutes before it accepts connections.
- 2Check the security group's inbound rules
aws ec2 describe-security-groups --group-ids SG_ID
You need an inbound rule that allows TCP port 22 from your computer's public IP.
- 3Check the subnet's route table
aws ec2 describe-route-tables --filters Name=association.subnet-id,Values=SUBNET_ID
Look for a route with destination
0.0.0.0/0whose target is the VPC's internet gateway. For IPv6 look for::/0.
Causes and fixes
Security group does not allow your IP on port 22
- HOW TO TELL
- No inbound rule for port 22, or the source is a single IP that has since changed.
- FIX
- Add an inbound rule for SSH from your current address. If your IP changes (home or corporate network), use the range your network uses instead of one address. The default security group for a VPC does not allow inbound SSH.
No route to the internet gateway
- HOW TO TELL
- The subnet's route table has no
0.0.0.0/0route to an internet gateway. - FIX
- Attach an internet gateway to the VPC if there is none, and add a
0.0.0.0/0route to it in the subnet's route table.
Network ACL blocks the traffic
- HOW TO TELL
- The subnet's network ACL does not allow inbound port 22 from you.
- FIX
- Allow inbound SSH from your IP and outbound traffic to the ephemeral ports (1024-65535).
No public IPv4 address
- HOW TO TELL
- The instance has only a private address.
- FIX
- Associate an Elastic IP address, or connect through another route such as Session Manager.
A firewall on your side
- HOW TO TELL
- You are on a corporate network or have a local firewall.
- FIX
- Ask whether outbound and inbound port 22 is allowed.
The instance is overloaded
- HOW TO TELL
- CPU is saturated in CloudWatch.
- FIX
- Scale out or move to a bigger instance type.
How to stop it coming back
- Prefer Session Manager or EC2 Instance Connect where you can, so you do not have to open port 22 to the internet.
- Keep SSH rules narrow and review them when your network changes.
Keep going
- Runbook: EC2 SSH: Permission denied (publickey) and unprotected key file
- Cheat sheet: AWS CLI
- Cheat sheet: SSH
- Lesson: the cloud topic in Learn
Sources
AWS documentation (docs.aws.amazon.com), read 18 Nov 2026.