johnsmith13579
johnsmith13579

Reputation: 41

AWS EC2 Instance connection reset by port 22

I have a aws ec2 p3.2xlarge instance. I can ssh and connect to it easily. However about after 20 minutes, while I am running a keras model on it, it resets the connection and I am kicked out with the error Connection reset by 54.161.50.138 port 22. I then am able to reconnect, but have to start training the model over again because my progress was lost. This happens every time I connect to the instance. Any idea why this is happening?

For ssh I am using gow which lets me run linux commands on windows - https://github.com/bmatzelle/gow/wiki I checked my public ip address before and after the reset and it was the same. I also looked at the cpu usage using amazon CloudWatch, and it was normal - 20%.

Upvotes: 0

Views: 6232

Answers (1)

johnsmith13579
johnsmith13579

Reputation: 41

I figured out a partial solution to this. In the instance terminal follow the following steps.

  1. run the command "tmux"
  2. in the new shell that pops up, execute the job
  3. detach from the tmux shell by using the shortcut (Ctrl+b then d)
  4. if the ssh connection resets, ssh to the instance again and run "tmux attach"
  5. the job should have kept on running and you can resume where you left off

Upvotes: 2

Related Questions