スキップしてコンテンツを表示

SSH to EC2 port 22: Operation timed out Operation Timed Out

0

My SSH connection to EC2 (Ubundu) suddenly stopped working. Not able to figure out what exactly the cause. I am not able to SSH from my MAC or From the Console. I cross checked the following

  1. Security group inbound rule has SSH (22) access.
  2. network ACL has both inbound and outbound SSH allowed rules enabled
  3. Changed IAM roles to see if thats causing this
  4. Run automation SSH troubleshooting which came back successful Please let me know how to resolve this.
質問済み 2ヶ月前68ビュー
4回答
0

When you encounter an "SSH port 22: Operation timed out" error with your EC2 instance, there are several potential causes to investigate beyond the steps you've already taken.

First, verify that your instance is actually in the "running" state and has passed all status checks in the EC2 console. Sometimes instances appear to be running but have underlying issues that prevent connections.

Since you've already confirmed security group inbound rules and network ACLs are properly configured, check these additional network components:

  • Ensure your VPC has an Internet Gateway attached
  • Verify the subnet's route table has a route to the Internet Gateway (0.0.0.0/0 pointing to the IGW)
  • Confirm your instance has a public IP address assigned

The issue could also be at the operating system level. The instance might have an OS-level firewall (like iptables) blocking incoming connections, or the SSH service might not be running properly.

Alternative access methods to try:

  • Use EC2 Instance Connect from the AWS Management Console (you mentioned trying from the console, but specifically try EC2 Instance Connect)
  • If configured, use AWS Systems Manager Session Manager to start a secure shell without needing SSH access
  • Try the VPC Reachability Analyzer to diagnose potential network configuration issues

As a last resort, you might need to stop and restart the instance, which will change the public IP address if you're not using an Elastic IP. This sometimes resolves connectivity issues, but note that any data on instance store volumes will be lost if you stop the instance.

If the instance contains important data, consider creating a snapshot of your EBS volumes before attempting more invasive troubleshooting steps.
Sources
The connection has timed out. No access to ec2 | AWS re:Post
Unable to SSH into AWS EC2 Instance – Connection Timed Out & Forgot Credentials | AWS re:Post
Can't connect to Linux instance even after the health status checks pass | AWS re:Post

回答済み 2ヶ月前
エキスパート
レビュー済み 2ヶ月前
  • Thank you . I did all these and stopped and started the instance as well. But still the getting operation timed out. Between I am able to connect to my application via my browser (did not mention it in my post).

0

hi,

Nice troubleshooting steps so far. A few clarifying questions:-

  1. as you mentioned:- "My SSH connection to EC2 (Ubundu) suddenly stopped working." ----------- it was working before, and when exactly did it stop?

  2. as mentioned:- "stopped and started the instance as well" if you stopped and started the instance (which would change the public IP), are you still able to access your application via browser?

This suggests:-

EC2 instance has Elastic IP attached, OR

Accessing through a load balancer, OR

Using a domain with dynamic DNS (Route 53 automation)

If your application still works after stop/start, public IP likely didn't changed, so need to focus SSH-issues, although SG blocking port 22 is most common reason.

if you can clarify?

Happy Troubleshooting

回答済み 2ヶ月前
  • Thanks Malini for your help. I was able to finally get to a solution by spinning a new instance and following the same configuration (even though its not solving the problem of the instance I was working with )

0

If you stoped and started your EC2 the Public IP Could have changed if you didnt assign an Elastic IP

Double check the IP Address you are using

エキスパート
回答済み 2ヶ月前
0

Thanks Gary, I double checked and used the new IP Address , but still it didnt work. Since I was in a time crunch, I spun up a new instance and had the same configuration (the configuration which I know of) and it worked perfectly fine. I still dont know what happened to the previous instance. So the issue got solved like that . Thanks for all the help though.

回答済み 2ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

関連するコンテンツ