Skip to content

Failed to connect to your instance, but status all good.

0

I can connect to my instance ec2 through my pc or dekstop, with 2 user ( default and adduser), but i can not connect in aws terminal for ec2 instance. Before that I can connect (2 days ago) in aws ec2 terminal, then open sudo nano editor but if I was using ctrl + w, my browser suddenly closed. my instance status and alarm : System status checks, Instance status checks, attached EBS status checks are All goods. and then if i connect again, failed to connect , thank you for your help me?

asked 2 years ago224 views

4 Answers
2

Based on your description, it seems you're experiencing an issue connecting to your EC2 instance using EC2 Instance Connect through the AWS console, despite being able to connect via other methods. This situation can occur due to various reasons, even when the instance status checks appear normal. Here are some potential causes and troubleshooting steps:

  1. Security Group Configuration: Ensure that the security group associated with your EC2 instance allows inbound SSH traffic (port 22) from the EC2 Instance Connect service IP range for your region.

  2. IAM Permissions: Verify that you have the necessary IAM permissions to use EC2 Instance Connect. You may need to check your IAM policy to ensure it allows the required actions for EC2 Instance Connect.

  3. Instance State: Although you mentioned the status checks are good, try rebooting the instance from the EC2 console. Sometimes, this can resolve connectivity issues.

  4. EC2 Instance Connect Installation: Confirm that EC2 Instance Connect is properly installed and configured on your instance. If you've made recent changes or updates to the instance, this could have affected the EC2 Instance Connect setup.

  5. Network Configuration: Double-check your VPC and subnet settings to ensure they're correctly configured for EC2 Instance Connect.

  6. Browser Issues: Since you mentioned your browser closed unexpectedly, try clearing your browser cache and cookies, or use a different browser to connect.

  7. System Logs: Review the system logs of your instance for any error messages or issues that might be preventing the connection.

If these steps don't resolve the issue, you may want to consider using AWS Systems Manager Session Manager as an alternative method to connect to your instance through the AWS console. This method doesn't rely on SSH and can sometimes work when EC2 Instance Connect is having issues.

If the problem persists, it would be advisable to contact AWS Support for further assistance, as they can provide more detailed troubleshooting based on your specific account and instance configuration.

Sources
Connect to an Amazon EC2 instance using EC2 Instance Connect Endpoint - Amazon Elastic Compute Cloud
Tutorial: Complete the configuration required to connect to your instance using EC2 Instance Connect - Amazon Elastic Compute Cloud
Unable to connect to EC2 using EC2 instance connect | AWS re:Post
Failed to connect to your instance EC2 Instance Connect is unable to connect to your instance. | AWS re:Post

answered 2 years ago

EXPERT

reviewed 2 years ago

  • ssh port 22 ( default) , i have changed to another port , is it required to back to ssh port 22? I can connect with my another port from my pc/dekstop.

    i just reboot instance from aws console and after that i coennect again but still failed to connect

2

Hello.

When connecting from the management console using EC2 Instance Connect, if you change from port 22, you will not be able to connect.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-connect-prerequisites.html

Ensure that the security group associated with your instance allows inbound SSH traffic on port 22 from your IP address or from your network. The default security group for the VPC does not allow incoming SSH traffic by default. The security group created by the launch instance wizard allows incoming SSH traffic by default. For more information, see Rules to connect to instances from your computer.

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

0

ok. Thank you for your good answer. but for the future, how can i safely change to ssh port 22 back again? in instance ec2 I changed in. sudo nano sshd_config... to port 22, and restart sshd but suddenly connection from my computer failed..... I have not change ufw firewall back to port22 and have changed security group inbound rule to port22? . suddenly my connection failed...? I can not connect my instance from my pc and also my aws instance connect?

answered 2 years ago

0

You need to get everything back to port 22, which I think you already know. Security group is easy, and it sounds like you've updated the port in /etc/ssh/sshd_config.

To get ufw into line you could consider disabling it at the next boot by adding ufw disable in the EC2 instance's user data - this is a script that is usually only executed on first bootup, but can be set ad hoc to run on the next bootup too https://repost.aws/knowledge-center/execute-user-data-ec2

The method for disabling ufw is here https://robinding.medium.com/aws-disable-ufw-in-ec2-linux-instance-979c678475ea

Obviously, before re-enabling ufw again make sure there is a rule in there for SSH on the correct port.

If that doesn't work for you, there is the EC2 Rescue Tool https://docs.aws.amazon.com/systems-manager/latest/userguide/automation-ec2rescue.html

EXPERT

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.