1 Answer
- Newest
- Most votes
- Most comments
0
The error "connection timed out" you are getting generally indicates that the server didn't respond to the client before the time out was reached. The following are common causes for this error:
- The security group or network ACL doesn't allow access.
- There's a firewall on the instance's operating system.
- There's a firewall between the client and the server.
- The host doesn't exist.
You can check if the source IP is not changed if you are using any VPN or home network.
As you mentioned that you are usually getting this error when the instance is active for 30 minutes or few hours, this can also happen when the instance is observing resource contention for example if the memory or CPU consumption is high.
Concluding this answer, I would suggest you to verify the following for the “Connection timed out” error you are receiving:
1. The instance's IP address or hostname is correct.
2. The instance is passing its health checks (both the instance & system status checks).
3. The security group of the instance allows incoming traffic on TCP port 22 from your source IP address. Source IP address may change if you are using VPN and there are any changes on the VPN side.
4. The network ACLs of instance subnet allows incoming traffic on TCP port 22 and allow ephemeral port for the outgoing traffic.
5. The route table of the instance’s subnet is configured properly to provide connectivity between EC2 instance and the SSH client.
6. There isn't a firewall at the OS level blocking the connection between SSH client and the EC2 instance.
7. The instance has enough resources available to serve the client request and is not in hung state. You can check instance screenshot for any error message, CloudWatch graph for status checks and CPU Utilization (also memory metrics if CloudWatch agent is configured).
8. When the instance is available and you are able to connect, check the OS level logs depending on the OS distribution you re using for further troubleshooting. You can mainly verify if there was any issue with the instance from the logs such as messages/syslog log file.
You can also follow the AWS Document here to troubleshoot such errors when connecting to the instance.
Relevant content
- asked 2 months ago
- asked 4 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 7 months ago