- Newest
- Most votes
- Most comments
Hello.
Could you please share specifically what kind of error message is displayed when connecting?
For example, if there is a timeout error, it may be because SSH is not allowed by the inbound rules of the security group set in EC2, or if SSH is not allowed by the network ACL of the subnet.
Therefore, I think it depends on the content of the error, but I think you need to troubleshoot it one by one while looking at the following documents.
https://repost.aws/knowledge-center/ec2-instance-connection-troubleshooting
If you are unable to connect due to an OS level problem, restarting EC2 may fix the problem.
You may also want to check the EC2 system log and look for error messages using the steps in the document below.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/troubleshoot-unreachable-instance.html#instance-console-console-output
If you can set up a serial console or Systems Manager Session Manager, please consider trying to connect from here.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-serial-console-prerequisites.html
https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-prerequisites.html
Hello,
For your issue there will be few reasons:
- If your instance is launched in private subnet then you need to have a natgate way to connect through ssh.
- If it is a public then once check the Inbound rule in Security group if the ssh is added and your ip should added in the source.
Once go through this link:-
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect-linux-inst-ssh.html
Relevant content
- asked 2 years ago
- asked 3 years ago
- AWS OFFICIALUpdated 2 years ago

Cannot connect to EC2 in a private subnet via NAT Gateway. NAT Gateway does not allow inbound traffic. https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html