sudo systemctl status ssh (Ubuntu/Debian) or sudo systemctl status sshd (AlmaLinux/Rocky), and check the port with sudo ss -tlnp.
Before you start
- You can’t use SSH to fix SSH. On a VPS, open the VNC console and log in there. On a dedicated server, open a ticket for KVM/IPMI access.
- Check the server is powered on and booted in the VPS Panel. A server that is still starting refuses connections for a short time.
- Commands use
sudo. As root, leave it out.
Refused or timed out?
The wording tells you where to look:Cause 1: The SSH service isn’t running
Most common after a reboot, a package upgrade or an edit tosshd_config that contains an error.
Check (on the console):
- Ubuntu / Debian
- AlmaLinux / Rocky
ssh.socket. Check that too: sudo systemctl status ssh.socket.Active: inactive (dead) or failed means SSH is off.
Fix: test the configuration first, then start the service.
/etc/ssh/sshd_config line 14: Bad configuration option: Prot, fix that line, run sshd -t again, then start SSH:
- Ubuntu / Debian
- AlmaLinux / Rocky
systemctl says the unit doesn’t exist, the SSH server isn’t installed. Install it with sudo apt install openssh-server (Ubuntu/Debian) or sudo dnf install openssh-server (AlmaLinux/Rocky).
Cause 2: SSH listens on a different port
If you or a script changed the SSH port, port 22 refuses connections. Check which ports SSH listens on:ListenAddress in /etc/ssh/sshd_config isn’t set to 127.0.0.1 or an old IP. SSH then refuses connections on your public IP.
Cause 3: A firewall or Fail2ban rule rejects you
A firewall (software that decides which connections reach your server) usually drops blocked traffic, which shows as a timeout. Rules that reject instead give “Connection refused”. Fail2ban, depending on its ban action, can do either after several failed logins. Check:- Ubuntu / Debian
- AlmaLinux / Rocky
REJECT or DENY rule on your SSH port, and for your own IP under Banned IP list.sudo ufw allow OpenSSH, or sudo firewall-cmd --permanent --add-service=ssh && sudo firewall-cmd --reload) and unban your IP with sudo fail2ban-client set sshd unbanip 198.51.100.25. Find your public IP by searching “what is my IP” on your computer.
Also check our Firewall panel if you use it, in case a rule there blocks the port.
Cause 4: You’re connecting to the wrong IP
A typo, an old IP or a domain that still points to a previous server sends you to a machine that doesn’t run SSH. Compare the IP in your command with the one in the VPS Panel, and connect by IP rather than by domain while you test.How to check it worked
From your computer:debug1: Connection established. followed by the login prompt.
Frequently asked questions
Why do I get “Connection refused” right after rebooting?
SSH starts near the end of the boot. Wait a minute and try again. If it still fails, the service didn’t start: check it on the VNC console as in Cause 1.Does “Connection refused” mean my server is hacked or down?
No. It proves the server is up and reachable, because it answered. Only the SSH port refused you.SSH works from the console but not from outside. Why?
SSH runs, so the port or firewall is the problem. Comparesudo ss -tlnp with your firewall rules and with the port you use in your SSH command.
Related guides
VPS and dedicated server guides
Every guide in this section.
SSH connection timed out
When the server doesn’t answer at all.
Locked out after a firewall change
Undo a rule that blocks SSH.
Manage services with systemctl
Start, stop and enable services.
Connect with SSH
The basics of logging in.
Checked against the official OpenSSH sshd manual and Ubuntu’s OpenSSH server guide on 4 November 2026; the “Connection refused” message,
sshd -t and ss -tlnp were tested on Ubuntu 24.04 LTS (OpenSSH 9.6). Service restarts and the AlmaLinux steps were not tested.Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026