SSH displays Connection refused or timeout
Distinguish SSH service stopped, bad port, firewall and network failure from noVNC. Allow SSH before enabling UFW.
Connection refused means that the machine is responding but no service accepts this port. A timeout, on the other hand, indicates that packets are not arriving or leaving.
Step-by-step procedure
-
Check IP and port
Copy the IPv4 from the panel and use the configured SSH port, usually 22.
-
Test from noVNC
Open the console then check systemctl status ssh and ss -lntp | grep :22.
-
Check the firewall
Allow SSH before enabling UFW. Also check the firewall rules of the VPS panel.
-
Read the logs
Use journalctl -u ssh -n 100 to spot configuration, key, or connection limit errors.
Repair the SSH service
sshd -t
systemctl restart ssh
systemctl status ssh --no-pager
ss -lntp | grep :22
Test the port from your computer
nc -vz YOUR_IPV4 22
# Windows PowerShell
Test-NetConnection YOUR_IPV4 -Port 22
Reopen SSH in UFW and Fail2ban
ufw allow 22/tcp
ufw status
fail2ban-client set sshd unbanip YOUR_IP
Read the error message
The exact ssh message tells you where to look.
- Connection refused: the VPS answers, but nothing listens on that port. SSH service stopped, port changed, or a firewall REJECT rule.
- Connection timed out: no answer at all. VPS stopped, wrong IPv4, or a firewall silently dropping packets: a DROP policy in UFW or in the panel "Firewall".
- No route to host: often a firewalld rejection on Fedora or CentOS Stream, or a stopped VPS.
Repair without SSH from the panel
First check the VPS status: "Stopped" needs a click on "Start", "Provisioning" means the installation is not finished. Then two tools work without SSH. The "Shell" tool, under "Additional tools", runs a short command as root through the QEMU Guest Agent, limited to 15 seconds: ideal for ss -lntp or systemctl restart ssh. The "noVNC console" gives you the VM screen and keyboard; pasting is not available there, so type the commands.
If you have enabled the panel firewall, open "Firewall options": with "Firewall enabled" and an "Input policy" of DROP, every port without an ACCEPT rule is blocked. In "Firewall", add an ACCEPT rule, protocol TCP, port 22.
Check that everything works
Inside the VM, ss -lntp should show a LISTEN line on port 22 with the sshd process. From your computer, test the port using the commands below: succeeded or TcpTestSucceeded : True confirms that the port is reachable.
Frequently asked questions
systemctl status ssh answers Unit ssh.service could not be found, why?
On Fedora, CentOS Stream and Arch Linux, the service is called sshd: use systemctl status sshd and journalctl -u sshd. If neither exists, install the openssh-server package from the "noVNC console".
The SSH service refuses to restart after a change, what should I do?
Run sshd -t: it shows the faulty file and line, for example Bad configuration option. Fix it, run sshd -t again until it prints nothing, then systemctl restart ssh.
I changed the SSH port and port 22 answers Connection refused, is that normal?
Yes: connect with ssh -p PORT root@YOUR_IPV4, after allowing that port in UFW and in the panel "Firewall" if you use it. On Ubuntu 24.04, if ssh.socket is active, it is the one opening the port: after the change, run systemctl daemon-reload then systemctl restart ssh.socket.
How do I unblock my IP address banned by Fail2ban?
From the "Shell" tool or the "noVNC console", fail2ban-client status sshd lists the banned addresses; unblock yours with the command below.