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.

alexdo
Site Moderator
Site Moderator badge
August 26, 2024

This isn’t normal behavior, and it could be related to server-side configurations, network issues, or even resource constraints. What you can do is to monitor the logs and wait a bit longer after the droplet deployment, before connecting via ssh and see if this gives different result.

Regards

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 ?

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/.

Try DigitalOcean for free

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

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

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

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
Animation showing a Droplet being created in the DigitalOcean Cloud console