Question

ssh: connect to host xxx.xxx.xxx.xxx port 22: Connection refused

Hey all, im currently having a really weird issue, upon creating a droplet with using a marketplace image (docker) im facing an issue where when i initially try and ssh onto the server i get a connection refused, i get this for couple of 45 seconds to a minute and then it lets me on, After i’ve performed some actions on my droplet i then exit the ssh session

if i forgot to do something on the droplet and try again to ssh onto it i once again get connection refused for a couple of seconds again, is there anyway i can resolve this? Is this some kinda of protection?

Thanks


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.

Bobby Iliev
Site Moderator
Site Moderator badge
August 25, 2024

Hi there,

I believe that most of the images from the Marketplace wait for all the services to be configured using cloud-init which sometimes takes a minute or so depending on the image that you are using.

Also, they include unattended upgrades, which could also mean that there are some extra security updates being installed during the initial creation. You could run htop once you connect to the Droplet or ps aux to see all of the running processes and confirm if this is indeed the case.

You can see the exact setup for some of the Docker Marketplace images here:

https://github.com/digitalocean/droplet-1-clicks/blob/master/docker-20-04/template.json#L28

Let me know how it goes.

- Bobby

KFSys
Site Moderator
Site Moderator badge
August 25, 2024

Heya,

That’s really weird indeed. Intermittent issues like the one you describe are really hard to pinpoint.

What I’ll recommend is to try and SSH to your Droplet through the Web Console and monitor the logs once you try to SSH the normal way. See if you can find anything usefull in those logs. Try the logs in /var/log/.

Thanks guys for the reply

i’ve quickly spun up a new droplet with just ubuntu on it and i’ve gotten similar errors where when i try and initially connect i get connection refused , looked at the logs and cant see anything noteworthy

if i cat auth.log: Aug 25 20:49:04 ubuntu-s-1vcpu-512mb-10gb-fra1-01 systemd-logind[694]: New seat seat0. Aug 25 20:49:04 ubuntu-s-1vcpu-512mb-10gb-fra1-01 systemd-logind[694]: Watching system buttons on /dev/input/event0 (Power Button) Aug 25 20:49:04 ubuntu-s-1vcpu-512mb-10gb-fra1-01 systemd-logind[694]: Watching system buttons on /dev/input/event1 (AT Translated Set 2 keyboard) Aug 25 20:49:05 ubuntu-s-1vcpu-512mb-10gb-fra1-01 sshd[811]: Server listening on 0.0.0.0 port 22. Aug 25 20:49:05 ubuntu-s-1vcpu-512mb-10gb-fra1-01 sshd[811]: Server listening on :: port 22. Aug 25 20:49:08 ubuntu-s-1vcpu-512mb-10gb-fra1-01 useradd[1055]: new user: name=lxd, UID=999, GID=100, home=/var/snap/lxd/common/lxd, shell=/bin/false, from=none Aug 25 20:49:08 ubuntu-s-1vcpu-512mb-10gb-fra1-01 sshd[846]: Connection closed by 51.9.152.25 port 54518 [preauth] Aug 25 20:49:11 ubuntu-s-1vcpu-512mb-10gb-fra1-01 sshd[811]: Received signal 15; terminating. Aug 25 20:49:12 ubuntu-s-1vcpu-512mb-10gb-fra1-01 sshd[1245]: Server listening on 0.0.0.0 port 22. Aug 25 20:49:12 ubuntu-s-1vcpu-512mb-10gb-fra1-01 sshd[1245]: Server listening on :: port 22. Aug 25 20:49:53 ubuntu-s-1vcpu-512mb-10gb-fra1-01 sshd[1960]: Accepted publickey for root from 162.243.190.66 port 58846 ssh2: ECDSA SHA256:a22YybabhAIW6T8Mc8D3ZmIC6Z25xFRb2YF6nWo7SUs Aug 25 20:49:53 ubuntu-s-1vcpu-512mb-10gb-fra1-01 sshd[1960]: pam_unix(sshd:session): session opened for user root(uid=0) by (uid=0) Aug 25 20:49:53 ubuntu-s-1vcpu-512mb-10gb-fra1-01 systemd-logind[694]: New session 1 of user root. Aug 25 20:49:53 ubuntu-s-1vcpu-512mb-10gb-fra1-01 systemd: pam_unix(systemd-user:session): session opened for user root(uid=0) by (uid=0)

Maybe the panel ui is a little misleading to when my droplet is actually fully setup and ready ?

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.