SSH Connection Refused on Ubuntu VPS: Reliable Diagnosis and Fixes

  • Home
  • Linux
  • SSH Connection Refused on Ubuntu VPS: Reliable Diagnosis and Fixes
SSH connection refused Ubuntu VPS troubleshooting at a computer workstation

SSH connection refused Ubuntu VPS troubleshooting at a computer workstation
Illustrative photograph by Dan Nelson / Unsplash.

An SSH failure can resemble a single problem from the client’s perspective: the terminal does not connect. In reality, refusal, timeout and authentication rejection describe different stages of a network session. Responding to each one with the same generic checklist wastes time and can make recovery more difficult.

The objective of a good diagnostic process is to identify the layer that failed—client settings, routing, firewall, listening service or authentication—and change only what is necessary. A server that refuses port 22 does not necessarily have a broken operating system. It may be listening elsewhere, rejecting connections through a firewall or running a daemon that never started successfully.

Start by interpreting the exact error

Connection refused generally indicates that the requested TCP endpoint is not accepting the connection or that a device explicitly rejects the traffic. Connection timed out is more consistent with packets receiving no useful response, perhaps because a firewall is dropping them or the network path is unavailable. Permission denied means the client reached an SSH service but authentication was unsuccessful.

These are diagnostic clues, not absolute proof of one root cause. Capture the full error string, the attempted IP, port, timestamp and source network before changing the server.

Step 1: confirm that the client targets the correct host

On the client computer, check the server IP address, SSH username and effective port. A simple explicit test is:

ssh -vvv -p 22 USER@SERVER_IP

Replace placeholders with your approved credentials; do not post private keys or passwords in a public support thread. The verbose output shows connection attempts and can distinguish failure before authentication from rejection during authentication. If your SSH service uses a nonstandard port, replace 22 with the verified port.

Step 2: use the provider’s console

If ordinary SSH fails, open the VPS provider’s browser or recovery console. This separates an operating-system problem from a remote network-access problem. Verify that the VM boots normally and that you have console access as an authorised administrator. If the provider reports an infrastructure incident or the VM is not running, investigate that first.

Avoid reinstalling the operating system as a default response. A reinstall may erase application files or make existing backups harder to recover. Preserve evidence and take an appropriate backup or snapshot before major changes when possible.

Step 3: determine whether the SSH daemon is running

From the console, inspect the service and its recent messages:

sudo systemctl status ssh
sudo journalctl -u ssh -n 100 --no-pager
sudo sshd -t

If sshd -t reports a configuration error, correct the specific file and line before attempting a restart. Do not repeatedly restart a failing service without reading its logs; restart attempts are not a diagnosis. The OpenSSH daemon manual describes the server’s role and configuration checks.

Step 4: confirm that an expected TCP port is listening

sudo ss -tlnp | grep -E ':(22|2222)\b'
sudo sshd -T | grep '^port '

The first example checks common illustrative ports; your service may use another port entirely. The second asks the daemon for its effective configuration. On installations using socket activation, systemd may determine listening behaviour, so examine the relevant SSH socket as well:

sudo systemctl status ssh.socket
sudo systemctl cat ssh.socket

Ubuntu packaging and cloud images differ. Do not change port settings until you have identified whether the service itself or an activated socket owns the listener.

Step 5: inspect UFW and upstream filtering

A running daemon can still be unreachable when a firewall rejects traffic. From the console:

sudo ufw status verbose
sudo ufw status numbered

Make sure the actual SSH port is permitted from your source network. If the hosting provider exposes an additional cloud firewall, review that separately; allowing a port at the guest level cannot bypass an upstream block. Our safe UFW firewall guide explains rule ordering and recovery.

Step 6: investigate the missing privilege-separation directory error

One notable SSH startup failure reports a missing privilege-separation directory, commonly /run/sshd. On systemd-based installations, runtime directories under /run are ephemeral and should be created by the appropriate service-management arrangement at startup. Manually creating the path can be a temporary diagnostic step, but does not establish why the expected creation failed.

If this error appears, inspect the service unit and packaging state before implementing a lasting fix. Avoid editing vendor unit files without understanding how upgrades replace them. A reliable resolution must survive reboot and preserve the intended directory ownership and permissions.

Step 7: distinguish a network fault from an authentication fault

Once the TCP connection reaches the daemon, troubleshoot the identity path separately. Review the requested username, public-key deployment, account state and SSH authentication logs. Changing passwords cannot fix a service that is not listening, and opening more firewall ports cannot repair an invalid authorised key.

Use a second terminal to validate recovered access and keep the console session open until the result is confirmed. For stronger authentication after recovery, follow the SSH hardening tutorial rather than improvising under incident pressure.

Step 8: verify a restart and a reboot

After correcting a specific fault, confirm that the SSH service is active, the correct port listens and a fresh connection succeeds. If the issue involved a runtime directory, temporary filesystem or service activation, consider a controlled reboot during an appropriate maintenance window. Verify SSH again after the reboot; a repair that works only until the next restart is incomplete.

Prevent recurrent SSH outages

Document the service configuration, create a dependable console recovery procedure, retain backups and monitor unexpected SSH service failures. Changes to authentication, port numbers and firewall rules should follow a small change-control checklist that includes a second-session test.

Before buying infrastructure, confirm the server access and recovery mechanisms available on the selected FyreHost VPS plan. If you are deploying a fresh machine, follow the Ubuntu VPS initial setup guide so SSH recovery is planned from the beginning rather than discovered during an outage.

Frequently asked questions

Why does SSH say connection refused?

The requested IP and port may not have a listening service, or a firewall may actively reject the connection. Verify the target, listening socket, service logs and network rules.

Is connection refused the same as permission denied?

No. Connection refusal occurs before successful SSH authentication, while permission denied indicates that the SSH service was reached but rejected the supplied identity or method.

Can low VPS RAM stop SSH from starting?

Severe memory pressure can cause processes to fail or be terminated, but low memory is not the only explanation. Check logs and out-of-memory events before attributing the fault to RAM.

How do I recover when SSH is inaccessible?

Use the provider’s authorised console, inspect SSH service status and logs, check the listening port and correct firewall or daemon errors. Reinstalling is usually unnecessary.

What is /run/sshd and why might it be missing?

It is a runtime directory used by some OpenSSH server configurations. It may be absent due to a service-startup or packaging problem, especially when runtime directory creation is not occurring as expected.

Will changing the SSH port fix connection refused?

Only if the client was targeting the wrong port and the daemon is already listening elsewhere. Arbitrary port changes can introduce additional firewall and service-activation problems.

Need Help?

Contact FyreHost 24/7/365 Award-Winning Support to help grow your online business!

FyreHost Help

24/7/365 Through the Chat Widget and WhatsApp

Customer Support Chat

24/7/365 Through the Chat Widget and WhatsApp

Customer Support Email

24/7/365 Through the Panel via Support Tickets

FyreHost Logo White

Get reliable hosting, domains, VPS services. Trust us to manage all your online needs from domain registration to VPS hosting.

Connect with us:

Copyright © 2026 FyreHost LTD Registered in UK with Company Number: 17242968, All Rights Reserved.