Unable to connect to EC2 using SSH or Instance Connect


Error with Instance connect:

Failed to connect to your instance EC2 Instance Connect is unable to connect to your instance. Ensure your instance network settings are configured correctly for EC2 Instance Connect. For more information, see Set up EC2 Instance Connect at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-connect-set-up.html.

Error with SSH: ssh: connect to host <ec2ip>.<region>.compute.amazonaws.com port 22: Operation timed out

I followed this post but still no resolution : https://repost.aws/questions/QUXaZXuLx9QAKGa1o5vdlfkw/ec2-instance-error-failed-to-connect

asked a year ago509 views
2 Answers

I don't know what your configuration looks like so my apologies for not being able to give specific guidance. Assuming you've followed the steps outlined in the link you shared, then perhaps it's some condition not met from the prerequisites. Can you check to see if you've checked all the boxes in terms of Region, AMI, grant permissions, and the like?

profile pictureAWS
answered a year ago


Since this is a timeout error, the most likely scenario is that this is related to the network connectivity.

I would check on the following

  1. If the instance has access to the internet
  2. Check if SSH port (22) is allowed for inbound traffic from the security group and if the network ACL allows both inbound and outbound for port 22.
  3. If you are using browser-based SSH connection (Using the EC2 connect option in the EC2 Console) you will need to allow inbound traffic in your security group from EC2 connect IP range for your region in addition to your own IP.

IP Ranges -> https://docs.aws.amazon.com/vpc/latest/userguide/aws-ip-ranges.html

Simply search for EC2_INSTANCE_CONNECT and look for the IP range for the region your instance is located.

      "ip_prefix": "",
      "region": "eu-north-1",
      "service": "EC2_INSTANCE_CONNECT",
      "network_border_group": "eu-north-1"

Hope this helps

profile picture
answered a year 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