Error connecting to your Ec2 instance: Connection timed out
Have you faced Fatal Error while accessing your AWS EC2 instances? What are the alternatives if the SSH access fails to the EC2 instance?
Firstly, you will check the security groups and network connectivities to the instance, once it’s ok, then you need to try and connect to the instance using AWS SSM Session Manager if all the prerequisites are met.
enter image description here
If you try to connect to your instance and get an error message Network error: Connection timed out or Error connecting to [instance], reason: -> Connection timed out: connect, try the following:
Check your Aws security group rules that is attached to your Ec2 Instance.
You need a security group rule that allows inbound traffic from your public IPv4 address on the proper port for ssh connection you have to enter Port 22 as shown in Screenshot.
enter image description here
If you already allow port number 22 in your AWS Security Group then check your connection with Aws Ec2 instance through Telnet command
sunnysharma@SMSUNNIK.local:~$ telnet 53.22.22.19 22
Trying 52.22.24.99...
Connected to ec2-53-22-22-19.compute-1.amazonaws.com.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
Connection closed by foreign host.
sunnysharma@SMSUNNIK.local:~$
enter image description here
Each time you restart your instance, a new IP address (and host name) will be assigned to your Ec2 Instance.
If your computer is on a corporate network, ask your network administrator whether the internal firewall allows inbound and outbound traffic from your computer on port 22 (for Linux instances) or port 3389 (for Windows instances).
If you have a firewall on your computer, verify that it allows inbound and outbound traffic from your computer on port 22 (for Linux instances) or port 3389 (for Windows instances).
Check the CPU load on your instance; the server may be overloaded. AWS automatically provides data such as Amazon CloudWatch metrics and instance status, which you can use to see how much CPU load is on your instance
Firewall get turned on? SSH server not running? Lots of things can cause this. – HopelessN00b – 2014-12-16T18:24:03.323
I'd Imagine. But what specifically? Throw me some bones here, I'm kinda dumbfounded. – t0mgs – 2014-12-16T18:25:00.160
Did you check the System Log in the AWS console? From the EC2 Instances screen, click the Action button and then "Instance Settings", "Get System Log". Look for any error there. – David Levesque – 2014-12-16T20:10:30.703
Not sure what to look for exactly. It's a HUGE log. – t0mgs – 2014-12-16T21:59:09.830
Do you see anything related to OpenSSH? You should at least see a line like this:
Starting OpenSSH server [ OK ]
– David Levesque – 2014-12-16T22:01:50.733There's on like that. A couple actually - I rebooted twice since I started the instance. – t0mgs – 2014-12-16T22:02:35.113
What happened between the time it was working and the time it stopped working? Did you make any config change? Installed any update? – David Levesque – 2014-12-16T22:08:18.473
Let us continue this discussion in chat.
– t0mgs – 2014-12-16T22:44:11.173I am facing same issue. There is nothing about SSh in AWS system logs Have you resolved it? How? – Amol Chakane – 2015-02-24T05:45:24.077