- Newest
- Most votes
- Most comments
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:
-
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.
-
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.
-
Instance State: Although you mentioned the status checks are good, try rebooting the instance from the EC2 console. Sometimes, this can resolve connectivity issues.
-
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.
-
Network Configuration: Double-check your VPC and subnet settings to ensure they're correctly configured for EC2 Instance Connect.
-
Browser Issues: Since you mentioned your browser closed unexpectedly, try clearing your browser cache and cookies, or use a different browser to connect.
-
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
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.
Is it possible to connect to EC2 with Systems Manager Session Manager? Although it is necessary to configure IAM roles on EC2, I think you can connect if you are using an OS with SSM Agent preinstalled on EC2. First, we recommend connecting to EC2 and checking whether the sshd log and listening port are set correctly. https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/connect-to-an-amazon-ec2-instance-by-using-session-manager.html
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
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
Relevant content
asked 2 years ago
- AWS OFFICIALUpdated 2 months 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