Menu
User

DropVPS Team

Writer: John hens

How to Fix SSH Connection Refused Error

How to Fix SSH Connection Refused Error

Publication Date

11/24/2025

Category

Articles

Reading Time

3 Min

Table of Contents

Seeing the “SSH Connection Refused” message can be frustrating, but this error is usually easy to fix. 

Step 1: Make Sure the SSH Service Is Running

Before troubleshooting any SSH connection error, you should first confirm that the SSH service is active on the server because a stopped or inactive SSH daemon is one of the most common reasons for “Connection Refused” issues.

sudo systemctl status ssh

If it's not running, start it:

sudo systemctl start ssh
ChatGPT said:

Step 2: Install the OpenSSH Server Package

To fix SSH connection errors on any Linux system, you must ensure the OpenSSH Server package is installed because without it your machine cannot accept incoming SSH requests.

sudo apt install openssh-server -y

Then confirm installation:

ssh -V

Step 3: Check Firewall Rules

A blocked SSH port is one of the most common causes of the “Connection Refused” error, so confirming that your firewall allows SSH traffic is essential for restoring access.

sudo ufw status

If SSH is not allowed, enable it:

sudo ufw allow ssh
ChatGPT said:

Step 5: Check Server IP and Network Connectivity

Before troubleshooting further, ensure your server’s IP address is correct and the network connection is active, as incorrect or unreachable networking details often cause SSH connection refused errors.

ip a

A quick ping test helps verify basic connectivity:

ping -c 4 <server-ip>

Step 6: Restart SSH and Networking

Restarting the SSH service and networking ensures that all recent changes take effect and can resolve persistent connection refused errors, making your server ready to accept new SSH connections.

sudo systemctl restart ssh

Restart network service (varies by system):

sudo systemctl restart NetworkManager

Step 7: Check for Fail2Ban Blocks 

Verifying Fail2Ban blocks can help identify if SSH connection attempts are being blocked due to repeated failed logins, ensuring that legitimate access is not accidentally denied.

sudo fail2ban-client status sshd

Unban your IP:

sudo fail2ban-client set sshd unbanip <your-ip>
Linux VPS
U
Loading...

Related Posts