ssh: connect to host port 22: Connection refused

When I run “docker-compose up” on my HOST machine(mac os) i’m getting this error:

ssh: connect to host port 22: Connection refused

My context is set correctly: export DOCKER_HOST=ssh://ai-dev@

Other commands, like “docker ps -a” or “docker run” works correctly with no errors…

ssh connection to the server works…

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I had an identical issue and was able to resolve it with the following instead. Not sure why this works over the other to be honest.

docker --context=remote compose up -d

Hi there,

Are you able to SSH to the server?

It sounds like that you might either have a firewall enabled on the host blocking the access to port 22, if this is the case you need to open port 22 or allow it for your IP address.

Another possible problem could be if the SSH service is not running on the host, you can check that with the following command once you login to the server via the web console:

systemctl status sshd

Also, another thing that I could suggest is to cross-check if the IP is correct.

Let me know how it goes. Regards, Bobby