`ssh: connect to host ... port 22: Connection refused`. How is it different from a timeout?
BeginnerTroubleshootingVPC and Connectivity
Answer
Likely causes → Refused means the packet arrived but nothing is listening, or the OS firewall rejected.
Diagnose →
aws ec2 get-console-output --instance-id i-0abc --latest --output text | tail -50
aws ssm start-session --target i-0abc
sudo ss -ltnp | grep 22
sudo systemctl status sshd
Fix →
- Start
sshd - Fix
sshd_config - Check
ufworiptables
Prevent → Bake sshd settings into the AMI.
More on VPC and Connectivity
`ssh: connect to host 3.250.1.1 port 22: Connection timed out`. Walk the checks.Beginner`Permission denied (publickey)` on a new EC2 instance.IntermediatePrivate instances cannot reach the internet; `curl: (28) Connection timed out after 10000 milliseconds`.IntermediateNAT gateway shows `ErrorPortAllocation` in CloudWatch and connections drop.IntermediateVPC peering is `active` but ping fails.IntermediateVPC Reachability Analyzer says `BLACKHOLE`. What does it mean?Advanced