can't connect my ec2 using ssh


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

some time later, I can't connect with my Ec2 using ssh . ec2 instance connect either . the error as above .

  • Did you try troubleshooting on your own? What have you tried / done?

asked 7 months ago314 views
2 Answers

Hi, please follow for detailled guidance on troubleshooting connection with Instance Connect.

It is most often an issue with security or IP routing in your VPC.



profile pictureAWS
answered 7 months ago
profile picture
reviewed 7 months ago

Approach 1

Please check the security settings. You might need to add inbound SSH connections from everywhere. If it's all okay, then follow approach two.

Approach 2

    1. Connect to your instance using SSH.
    1. Use the SSH key pair that was assigned to your instance when you launched it and use the default user name of the AMI that you used to launch your instance , for Amazon Linux 2, the default user name is ec2-user
    1. Use the following command to SSH into your instance:

    ssh -i my_ec2_private_key.pem ec2-user@<your instance's public DNS name>

  • Install the EC2 Instance Connect package on your instance. For Amazon Linux 2, use the yum install command.

    sudo yum install ec2-instance-connect

Approach 3

  1. Go to your AWS EC2 console
  2. Select your instance that is not able to connect
  3. Stop your instance
  4. Go to Actions -> Instance Settings -> Edit User Data
  5. Add user data in to update Firewall setting etc in user data
  6. Save this and restart instance.
profile picture
answered 7 months 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