Fix: SSH Connection Refused / Timeout on Your VPS

Estimated reading: 3 minutes

If you’re getting Connection refused, Connection timed out, or ssh: connect to host port 22: Connection refused when trying to SSH into your VeerHost VPS, this guide covers every likely cause and how to fix it step by step.

Cause 1: Wrong IP Address or Port

Double-check your SSH command. The correct format is:

ssh root@YOUR_VPS_IP

If your VPS uses a custom SSH port (e.g., 2299), you must specify it:

ssh -p 2299 root@YOUR_VPS_IP

Verify the VPS IP is correct by logging into your VeerHost client area and confirming the IP shown on your VPS dashboard.

Cause 2: SSH Service is Not Running

If the SSH daemon crashed or was stopped, you won’t be able to connect. Access your server via the VeerHost VPS Console (available in your client area — no SSH needed), then run:

systemctl status sshd

If it’s inactive or failed, start it:

systemctl start sshd
systemctl enable sshd

On some systems the service is called ssh instead of sshd:

systemctl start ssh
systemctl enable ssh

Cause 3: Firewall Blocking Port 22

If UFW or iptables is blocking port 22, SSH connections will be refused. Via the VPS console, check UFW status:

ufw status

If UFW is active and port 22 is not listed, allow it:

ufw allow 22/tcp
ufw reload

To check iptables directly:

iptables -L INPUT -n -v | grep 22

Cause 4: Incorrect SSH Config (sshd_config Error)

A typo in /etc/ssh/sshd_config can break SSH completely. Via the VPS console:

sshd -t

This tests the config file and shows any errors. Fix the reported lines, then restart SSH:

systemctl restart sshd

Cause 5: SSH Package Not Installed

On some minimal OS images, the SSH server may not be installed. Via the VPS console:

apt update
apt install -y openssh-server
systemctl enable ssh
systemctl start ssh

Cause 6: Too Many Authentication Failures

If you have multiple SSH keys in your ~/.ssh/ directory, SSH may try them all and hit the server’s MaxAuthTries limit. Force a specific key:

ssh -i ~/.ssh/id_ed25519 root@YOUR_VPS_IP

Or temporarily disable the SSH agent:

ssh -o IdentitiesOnly=yes -i ~/.ssh/id_ed25519 root@YOUR_VPS_IP

Cause 7: VPS is Overloaded or Crashed

If the server is completely unresponsive, it may be locked up due to high load or OOM (out of memory). Log into your VeerHost client area and use the VPS Console to check. If the server is frozen, use the control panel to perform a hard reboot. After rebooting:

# Check what's eating memory
free -h

# Check CPU and process usage
top

# Check disk space (a full disk also kills SSH)
df -h

Cause 8: Banned by Fail2Ban

If fail2ban is installed and you entered the wrong password too many times, your IP may be banned. Via the VPS console:

# Check if your IP is banned
fail2ban-client status sshd

# Unban your IP (replace 1.2.3.4 with your actual IP)
fail2ban-client set sshd unbanip 1.2.3.4

Still Can’t Connect?

Use the Emergency Console in your VeerHost client area to access the server without SSH. From there you can diagnose any issue. If you’re still stuck, open a support ticket and include your VPS IP and the exact error message.