ssh:Connection timed out

Posted April 4, 2017 26.6k views

I disconnected from server and could not connect to it anymore after setting up a program running on server today, when i try to login I get following error:
ssh: connect to host port 22: Connection timed out

verbosity mode:
ssh -vvv
OpenSSH7.2p2, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh
debug2: resolving “” port 22
debug2: sshconnectdirect: needpriv 0
debug1: Connecting to [] port 22.
debug1: connect to address port 22: Connection timed out
ssh: connect to host port 22: Connection timed out
how to solve it???

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 answers

i found the problem: the program i run took too many memory and CPU and whole system just died. I had to go to console on digitalocean to reboot the droplet and problem fixed

Hi @zz386
Can you login via the Console on the control panel on DigitalOcean? Seems like something might have crashed your SSH daemon or maybe the firewall was enabled.

I resolved it. It turns out that when we create a droplet using the digital ocean UI, there is a section near the bottom which allows you to pick the SSH key that you have already added to your account. That step is not obvious when you haven’t set up SSH keys yet on digital ocean and start by creating your first droplets.
So I erased existing droplets, and created new ones again, this time with the SSH key that I had set up in advance. Now my SSH sessions start up fine on the droplets.

Probably there is a way to fix it without the above steps, but I couldn’t get that to work: ssh-copy-id username@remotehost fails because ssh username@remotehost already fails (in my case, connection timed out).