How to Fix SSH Connection Refused
The SSH connection refused message means that your server refuses the connection on the SSH port. Usually the SSH service is not running, a firewall blocks the port or you are using a different port than the server expects. Fortunately it can usually be fixed quickly. Below you read per cause what to check and how to fix it.
First: reach your server another way
If SSH does not work, at Xitens you can always reach your VPS via the noVNC console in the client area. It lets you work directly on the console and run the checks below.
Cause 1: the SSH service is not running
Check the status of the SSH service and start it if necessary:
systemctl status ssh
systemctl enable --now ssh On AlmaLinux the service is called sshd. If SSH is not installed, install it with apt install openssh-server -y.
Cause 2: the firewall blocks the port
View the UFW rules and allow SSH:
ufw status
ufw allow OpenSSH On AlmaLinux you check firewalld with firewall-cmd --list-all.
Cause 3: you are using the wrong port
If you changed the SSH port, specify it when connecting. On the server, ss shows which port SSH listens on:
ss -tlnp | grep ssh
ssh -p 2222 root@JOUW-IP Cause 4: your IP address is blocked by Fail2ban
After too many failed login attempts, Fail2ban temporarily blocks your IP address. Check and unblock it like this:
fail2ban-client status sshd
fail2ban-client set sshd unbanip JOUW-EIGEN-IP Cause 5: an error in the SSH configuration
A typo in the configuration file can prevent SSH from starting. Test the configuration:
sshd -t If this command returns an error, fix the line it mentions in /etc/ssh/sshd_config and restart SSH.
Cause 6: the server is not reachable
Check from your own computer whether the server responds. If it does not respond, check in the client area whether your VPS is switched on.
ping JOUW-IP Related articles
Rent a Linux VPS with root access
Ubuntu, Debian or AlmaLinux with full root access via SSH, enterprise Ceph storage with high availability and hosting in Amsterdam.