AWS Builder Center
Troubleshooting AWS EC2 Instances

Troubleshooting AWS EC2 Instances

Can't connect to your AWS EC2 instance? Learn how to troubleshoot SSH and RDP connection failures by checking security groups, key pairs, public IP addresses, VPC routing, and IAM permissions. This beginner-friendly guide walks through common causes, practical diagnostic steps, and safer configuration practices to help you build confidence with AWS.

Troubleshooting AWS EC2 Instances When You Can’t Connect

Common issues. Step-by-step checks. Practical solutions.
You launch an EC2 instance, obtain its public IP address, and try to connect—but the connection fails. This is a common learning challenge for AWS beginners, and understanding how to troubleshoot it is an important step toward building real cloud skills.
This guide explains common causes of EC2 connection failures, how to investigate them systematically, and how to configure access more securely.

1. Understand the Error Before Changing Anything

Start by identifying the connection method and the exact error message.
  • Connection timed out: Often indicates a network path, firewall, security group, routing, or reachability problem.
  • Permission denied (publickey): Usually points to an SSH username, key pair, or key-file permission issue.
  • Remote Desktop connection fails: Check Windows instance status, RDP access, network configuration, and credentials.
These errors provide clues. Don't immediately change every setting—check one possible cause at a time.

2. Check These Six Things

Step 1: Verify the instance state.
Open the EC2 console and confirm the instance is running and has passed its status checks. A running instance can still have connectivity problems.
Step 2: Review the security group.
For Linux SSH access, TCP port 22 must be allowed from your trusted source IP. For Windows RDP, TCP port 3389 is commonly required. Avoid opening these ports to the entire internet unless there is a specific, justified need.
Step 3: Confirm the SSH key and username.
Use the private key associated with the instance's key pair and the correct username for your AMI. Common defaults include ec2-user for Amazon Linux and ubuntu for Ubuntu images.
Step 4: Check the public IP address.
If connecting directly over the internet, verify that the instance has a public IPv4 address or an associated Elastic IP and that you're using the correct address.
Step 5: Inspect the VPC and routing.
A public subnet normally needs a route to an Internet Gateway, along with the necessary network configuration. Also check network ACLs and the route table if connectivity still fails. A NAT Gateway alone does not provide unsolicited inbound internet connectivity to a private instance.
Step 6: Review permissions and alternative connection methods.
If you're using AWS Systems Manager Session Manager, verify the required instance configuration, SSM Agent, IAM permissions, and network access to Systems Manager endpoints. IAM permissions for your AWS account and the instance's operating-system login credentials serve different purposes.

3. Example: Troubleshooting an SSH Timeout

Suppose your EC2 instance is running, but your SSH client reports a connection timeout.
Work through this sequence:
  1. Confirm the public IP address is correct.
  2. Check that the security group permits TCP port 22 from your current public IP.
  3. Verify the subnet's route table and Internet Gateway configuration.
  4. Review network ACL rules and other network controls.
  5. Confirm the instance is healthy and the SSH service is available.
If the error changes to Permission denied (publickey), shift your attention to the username, private key, and authentication configuration rather than repeatedly changing network rules.

4. Example Security Group Rule

For a Linux instance that you administer over SSH, a more secure inbound rule could look like this:
SettingExample
TypeSSH
ProtocolTCP
Port22
SourceYour trusted public IP address /32
Avoid using 0.0.0.0/0 for SSH in production. Restrict access to trusted addresses or use a suitable alternative such as Systems Manager Session Manager.

5. Additional Troubleshooting Tips

  • Use EC2 instance status checks to identify infrastructure or instance-level health problems.
  • Review system logs and console output when the operating system may not be starting correctly.
  • Use CloudWatch where relevant for available metrics and monitoring data.
  • Check the AWS Health Dashboard for regional service events.
  • Remove temporary access rules and resources when they're no longer needed.
Always check current AWS pricing before creating resources for troubleshooting, and clean up anything you no longer need.

Keep Learning, Keep Exploring

Troubleshooting isn't about knowing every answer immediately. It's about asking the right questions, gathering evidence, and testing possible solutions systematically.
Every connection problem you investigate can teach you more about networking, security, IAM, and cloud infrastructure. Document what you learn, share your findings, and help another beginner who might be facing the same challenge.
What's the most challenging AWS issue you've encountered so far, and what helped you solve it? Share your experience in the comments so we can learn from one another.
#AWS #AmazonEC2 #AWSTroubleshooting #CloudComputing #AWSCommunity
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article