AWS Builder Center

Troubleshooting AWS EC2 Connectivity: 5 Common Problems and How to Fix Them

Launching an Amazon EC2 instance is one of the first things many people learn when exploring Amazon Web Services (AWS). However, getting an instance running does not always mean you can successfully connect to it. You might encounter an SSH connection timeout, an unreachable web application, or a server that appears to be running but cannot communicate with other resources.

1. Incorrect Security Group Rules

Security groups act as virtual firewalls for AWS resources. They control inbound and outbound traffic associated with an EC2 instance.
For example, if you want to connect to a Linux instance using SSH, TCP port 22 must be allowed by the instance's security group. For a web server, HTTP traffic typically uses TCP port 80, while HTTPS uses TCP port 443.
How to troubleshoot:
  • Open the EC2 console and select your instance.
  • Check the security groups associated with its network interface.
  • Review the inbound rules and verify that the required port is allowed from the appropriate source.
  • Check outbound rules if the instance cannot initiate the required connections.
Avoid opening administrative ports to the entire internet. For SSH, restrict access to your own trusted public IP address whenever possible.

2. Incorrect Network Configuration

Even with correct security group rules, an instance may remain unreachable because of its network configuration.
An EC2 instance in a public subnet generally needs a route to an internet gateway and a public IPv4 address or another appropriate public addressing configuration to be directly reachable from the internet.
A private subnet, on the other hand, is typically designed for resources that should not accept direct inbound connections from the public internet.
How to troubleshoot:
  • Verify the instance's VPC and subnet.
  • Inspect the subnet's associated route table.
  • Check whether the required routes exist.
  • Confirm that an internet gateway or another appropriate network path is configured.
  • Verify that the instance has the addressing required for your connection method.
A useful lesson is that a public IP address alone does not guarantee internet connectivity. Routing and security controls must also allow the traffic.

3. The Application Is Not Running

Sometimes the network configuration is correct, but the application itself is unavailable.
For example, you may be able to connect to an EC2 instance through SSH while a website hosted on that instance fails to load. This could indicate that the web server is not running or is not listening on the expected port.
How to troubleshoot:
On a Linux instance, you can check the status of a service using:
sudo systemctl status httpd
This example applies to systems using the Apache HTTP Server service named  httpd , such as Amazon Linux configurations that use that service name.
To check listening ports, run:
sudo ss -lntp
These commands help determine whether the service is active and whether a process is listening for connections.
Remember that service names and installation procedures differ depending on the operating system and software you use.

4. Network Access Control Lists and Routing Issues

Network access control lists (network ACLs) provide another layer of traffic control at the subnet level. Unlike security groups, network ACLs are stateless, meaning inbound and outbound traffic must be allowed separately.
For example, a network ACL might allow an inbound request but block the corresponding response traffic if the required outbound or ephemeral port rules are missing.
How to troubleshoot:
  • Review the network ACL associated with the subnet.
  • Check inbound and outbound rules, including their order.
  • Verify that the necessary response traffic is permitted.
  • Inspect route tables for incorrect or missing routes.
  • Consider whether network connectivity between multiple subnets depends on additional routing or security configurations.
When troubleshooting, examine the entire communication path instead of focusing only on the EC2 instance.

5. Incorrect SSH Credentials or Key Permissions

If your instance is reachable but SSH authentication fails, the problem may be related to credentials rather than networking.
Common causes include using the wrong private key, specifying an incorrect username, or using a private key with permissions that are too permissive.
For example, on Linux or macOS, you can restrict access to a private key file with:
chmod 400 my-key.pem
Then connect using the appropriate username and public IP address:
ssh -i my-key.pem ec2-user@YOUR_PUBLIC_IP
The username  ec2-user  is commonly used for Amazon Linux, but other operating systems may require a different username.
If the error is a timeout, investigate networking first. If the error indicates that the server rejected your authentication, investigate the username, key pair, and SSH configuration.

A Practical Troubleshooting Checklist

When an EC2 instance cannot be reached, work through the following checks in order:
  1. Confirm that the instance is running and its status checks have passed.
  1. Identify the connection method and required port.
  1. Verify security group rules.
  1. Check subnet configuration, route tables, and addressing.
  1. Inspect network ACLs and other network controls.
  1. Confirm that the target service is running and listening.
  1. Investigate credentials if the network connection succeeds but authentication fails.
Following a consistent troubleshooting process can help narrow down the cause without making unnecessary changes to your infrastructure.

Conclusion

EC2 connectivity problems are a useful opportunity to learn how AWS networking and security work together. A failed connection may be caused by a firewall rule, an incorrect route, a missing public IP address, an application issue, or an authentication problem.
Rather than changing multiple settings at once, test one layer at a time and use the available logs, service status information, and network configuration to identify the root cause.
These troubleshooting skills are valuable beyond EC2. They also provide a foundation for understanding VPC networking, application deployment, cloud security, and day-to-day cloud operations.
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