- Newest
- Most votes
- Most comments
If you're unable to SSH into your EC2 instance despite it showing as running and having no alarms, there are several potential causes and troubleshooting steps to consider:
-
Security Group Configuration: Ensure that the security group associated with your instance allows inbound SSH traffic (port 22) from your IP address or network.
-
Network Configuration: Verify that your instance is in a public subnet with a route to an internet gateway. Check that the route table for the subnet includes a route to the internet gateway (0.0.0.0/0 to igw-xxxxxxxx).
-
Public IP: Confirm that your instance has a public IP address assigned if you're trying to connect from the internet.
-
Instance State: Although the instance shows as running, check that it has passed all status checks in the EC2 console.
-
SSH Service: There might be an issue with the SSH service on the instance itself. This could be due to misconfiguration, a full disk, or other system issues.
-
EC2 Instance Connect: If you're unable to connect via the AWS Console's "Connect" feature, ensure that EC2 Instance Connect is properly installed and configured on your instance.
-
Network ACLs: Check that the Network ACL associated with your subnet allows inbound and outbound traffic on port 22.
-
VPC Flow Logs: Consider enabling VPC flow logs to monitor the traffic reaching your instance and diagnose any networking issues.
-
System Logs: Review the system logs in the EC2 console for any error messages or indications of what might be causing the connection issues.
-
Reboot: As a troubleshooting step, try rebooting the instance from the EC2 console.
If none of these steps resolve the issue, you may need to stop and start the instance (note that this will change the public IP if you're not using an Elastic IP). As a last resort, consider using the EC2 Rescue for Linux tool to diagnose and fix common issues preventing connections.
If the problem persists across multiple instances or regions, it may indicate a broader account or regional issue, in which case contacting AWS support for further assistance would be advisable.
Sources
Failed to connect to your instance, but status all good. | AWS re:Post
Error establishing SSH connection to your instance. Access to EC2 has been lost | AWS re:Post
EC2 Instance Connectivity Issue Despite Instance Running Successfully | AWS re:Post
Can't connect to ec2 instance | AWS re:Post
Unable to ssh to an EC2 instance | AWS re:Post
System Logs: Review the system logs in the EC2 console for any error messages or indications of what might be causing the connection issues.
This is great advice, if only it were obvious where to "Review the system logs in the EC2 console"
answered a year ago
Hello.
You can check this by selecting the EC2 instance and clicking the actions button in the upper right.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/troubleshoot-unreachable-instance.html#instance-console-console-output
You will also need to install the SSM Agent on your EC2 instance in advance, but you can also try connecting using Systems Manager Session Manager.
https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-getting-started.html
Relevant content
asked 2 months ago
