AWS EC2 connection reset by peer and frequent timeouts

Viewed 2726

I have an EC2 instance that I have been running for months. I'm usually able to connect to it, but often I get timeout errors when connecting (about 2 times a week). I usually have to either reboot the instance or stop and start it again. I've opened port 22 for all IP.

I've gone through AWS's troubleshooting guide and other posts on stackoverflow, but to no avail.

Why is connecting to EC2 so unreliable? Here's an example of "Connection reset by peer" error I got today. After rebooting the instance, it is working again but why do I get timeout errors so often?

Any help is much appreciated! Thanks!

ssh -i "mykey.pem" ec2-user@ec2-XX-XXX-XX-XX.compute-1.amazonaws.com -v

-----
OpenSSH_7.5p1, LibreSSL 2.5.4
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 52: Applying options for *
debug1: Connecting to ec2-34-204-14-14.compute-1.amazonaws.com [34.204.14.14] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file crypto.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file crypto.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.5
ssh_exchange_identification: read: Connection reset by peer
1 Answers

Check for ec2 2/2 instance check errors and restart the instance

Related