port 22: Connection timed out

Today, I have established a droplet succesfully. The information: 512MB Ram 20GB SSD Disk San Francisco 1 CentOS 6.7 x64


However, when I try ssh root@ The error occurred: ssh: connect to host port 22: Connection timed out

Also, when I try ping It failed to connect to the server

But, I can connect to the gateway. ping is successful.

How can I solve this problem.

Thanks very much.

Best wishes


Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Not sure if anyone needs anymore discussion on this, but I faced the same problem and got a lead from this post to fix. Yes, I think port was blocked. When I did sudo ufw allow 22 from console and tried to connect, I was able to connect


Login to your digital ocean account and go to launch console under access in your droplet. then type in your username and then your password.

Once you are logged in type $ sudo ufw allow 22

Try again in your terminal and it will work. :)

Hello! I had the same problem and it persists even after enabling port 22 in the firewall.

In my case (I estimate that for having too many ssh keys) I had to initialize the ssh agent and add the key “manually”. And it worked.

The steps I followed were:

To initialize the ssh agent

eval $ (ssh-agent -s)

To add the key

ssh-add -i ~ / .ssh / key

— If your password has a paraphrase, you should insert it — In my case, the key was in the ~ / .ssh / directory and was called “key”, check the names of your files and replace them.

To enter the Droplet via ssh

ssh -i ~ / .ssh / key root @ droplet-ip

— It is important to add the argument “-i” to the ssh command and tell it the full path where your key is located — Then you can indicate with which user and to which IP you will connect

I hope it works for you too.