SSH connection to a newly created Ubuntu EC2 instance fails



I launched an Ubuntu EC2 instance from AWS console, and set the security rule to permit SSH connection from anywhere. I chose Ubuntu from "Quick Start" menu as the screen capture shown below.

When I tried to connect to it from my laptop via SSH, it failed with "Connection timeout". I also tried the "connect" to the instance button on AWS console, but it told that the instance was somehow unreachable.

I was trying to connect like this:

ssh -i "$HOME/.ssh/my-key.pem" ubuntu@<pulibc-ip-here>

Was there any configuration or procedure I was missing?

I did just the same way as I successfully connected about a half year ago, so I guess there might have been a change on AWS.

Enter image description here

asked 2 years ago691 views
2 Answers
Accepted Answer


Have you seen the following troubleshooting information in the EC2 User Guide?

Check the section that talks specifically about "Connection timed out":

It's not clear to me whether you've successfully connected to this instance or another instance half a year ago? If you connected to this instance, have you stopped and then started your instance since you last connected to it? When you stop your instance, the public IPv4 address that Amazon EC2 automatically assigned to the instance on launch or start is lost. When you start your instance, a new public IPv4 address is assigned. Check that this IP address appears in your connection command.

I hope the above helps!

Kind regards, Marilyn

answered 2 years ago
profile picture
reviewed 2 months ago


It turned out that I mistakenly deleted the internet gateway attached to the VPC of that instance. So re-creating an internet gateway and attaching it to the VPC again solved the connection issue.

By the way, I meant that I could connect other instances a half year ago, not the one I deal with now. But they were inside the same VPC.

The provided link reminded me to refer the route of VPC, that was the cause of this issue.

Thank you for letting me know :-)

Best wishes, Ryosuke

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions