SSH Connection refused in DigitalOcean | Causes & fixes

Are you happy with your current hosting provider ?

You are having trouble connecting to SSH in DigitalOcean and you are not sure what to do. Hostnats is looking out for your best interests.

As part of our Managed DigitalOcean Cloud services, we at Hostnats have answers to all of your questions, big or small.

If you’re having trouble connecting to your DigitalOcean server via SSH, check out how our Support Team was able to assist a customer.

How to resolve the error: SSH Connection refused in DigitalOcean

Administrators of servers can use SSH to connect to the server from an untrusted network without fear of being tracked down or hacked. It’s a great way to connect to a Linux server located in another location. In addition, it is included by default in most Linux distributions.

It’s possible, however, that the request for a connection will be turned down. SSH connection refused in DigitalOcean is the most common error message we see. When the host rejects the request, this message is sent to droplet owners. This particular error has four possible causes.

  • Failed to Establish SSH Tunnel
  • Incorrect selection of SSH port
  • Firewall’s restriction
  • Wrong Host IP Address Selection in the firewall

Cause & Fix: SSH Service Connection Fails

sshd daemon is used to listen for incoming connections by the SSH service in this case. Besides that, it’s also responsible for things like terminal connections and user authentication. SSH connection refusal errors occur in Digital Ocean servers if the service fails to connect.

We can fix this by determining the root cause of the problem, according to our Support Technicians. Disk errors, traffic congestion, DDoS attacks, and so on are all possible causes.

It may be necessary to kill and restart the backend service if it is not responding or failing. The SSH service can be restarted by running the following command:

systemctl restart sshd

SSH will then be ready to use by running the following command:

sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
Active: active (running) since Mon 2018-12-19 10:00:22 GMT; 3 days ago

Cause & Fix: Wrong SSH Port Selection

Another possible cause of the SSH Connection Refused error in DigitalOcean is the selection of the incorrect SSH Port. If you receive this error, it’s likely that you’re trying to connect to your servers using the wrong port.

To fix the problem, the SSH port has been suggested by our support staff. The first step is to access the droplet through a console and check the SSH configuration file. This is the default location for the SSH configuration file, which is located in /etc/ssh.

Once the file has been opened, we must locate the Port Parameter and alter it. We can also use the netstat command to see if the SSH port is open.

Cause & Fix: Restriction of the firewall

Incorrect firewall configurations can also result in the SSH connection being refused. The firewall rules should be checked first, according to our Support Technicians. Using the following command, we can verify that the external network can reach the SSH port.

telnet IP PORT

IP and PORT must be replaced with the droplet’s IP address and SSH port number, respectively.

Cause & Fix: Wrong Host IP Address Selection

An incorrect IP address or IP conflict could be the final cause of SSH connection refusal. In other words, the error appears if multiple droplets share the same IP address.

To resolve the IP conflict, our Support Team recommends navigating to PTR Records under Networking in the Manage section of the DigitalOcean control panel.


All four fixes suggested by Hostnats’ expert support engineers are effective in resolving the error: In DigitalOcean, an SSH connection was refused.