SSH connection refused: what it is, causes, and 6 effective methods to fix it (2024)

SSH

Jul 23, 2024

Nadia D.

5min Read

SSH connection refused: what it is, causes, and 6 effective methods to fix it (1)

When using an SSH (Secure Shell) protocol to access a remote server, you may encounter an SSH “Connection refused” error message. It is a common error indicating that your SSH server fails to accept connections.

In this tutorial, we will explain what the SSH “Connection refused” error is and its potential causes. Also, we will walk you through the six effective methods to resolve this SSH connection error.

Download ultimate SSH commands cheat sheet

What is SSH connection refused?

SSH “Connection refused” is a network communication protocol failure that occurs when connecting to an SSH server. When the SSH connection fails, you won’t be able to deploy secure encryption on your site and run more advanced tasks such as remote commands. Usually, this error is caused by a wrong SSH port, incorrect credentials, and a disabled SSH service.

What causes the SSH connection refused error

In this section, we will uncover the most common SSH “Connection refused” causes.

Error code Connection refused
Error typeNetwork communication protocol error
Error causesNetwork problem
Incorrect SSH installation
Wrong credentials
Security system configuration

SSH port is wrong

The SSH port grants you access to a remote server. This is why it’s important to ensure you’re pointing at the right one when opening the SSH port. Otherwise, you will get the SSH “Connection refused” message when trying to perform a remote connection.

Credentials are incorrect

Typing in the wrong credentials a few times will result in failed login attempts, causing the SSH “Connection refused” error. Make sure you’re entering the correct username, password, hostname, and port to avoid an SSH connection failure.

SSH client is not installed

Another common issue that causes the SSH “Connection refused” error is not having SSH client software installed on your localhost. An SSH client enables a secure connection to SSH servers. In short, you won’t be able to initiate a connection request to an SSH server without the SSH client in the first place.

SSH Daemon is not installed on the server

Besides the SSH client, you also need to install SSH Daemon to access a remote server from your local device. SSH Daemon will accept authenticated requests made through an SSH Client. An SSH “Connection refused” issue may occur when the SSH Daemon is not properly configured.

SSH services are disabled

Traffic surges and DDoS attacks are possible reasons for a disabled SSH service. When your SSH service is down, SSH Daemon won’t be able to accept connections to a remote server. Therefore, you will face an SSH “Connection refused” message.

Firewall prevents SSH connection

When a firewall protects your server from unauthorized incoming connections, it may also block SSH connections. You will need to apply specific firewall rules to enable the SSH connection requests and avoid the SSH “Connection refused” error.

6 ways to fix the SSH connection refused error

After identifying what has caused the SSH “Connection refused” error, it’s time to fix it.

In this section, we will take a closer look at the six proven methods to do so.

1. Change the SSH port number

An SSH connection runs on port 22 by default, but the port may be closed when left unused for a while due to security reasons. Therefore, ensure the SSH port is open before connecting to a remote server.

Use the following command to check for ports listening to requests:

sudo lsof -i -n -P | grep LISTEN

However, the default open port 22 is more vulnerable to cyber attacks. We encourage you to use a different port to reduce security risks.

Here at Hostinger, we use the custom SSH Port 65002. Hence, you will see 65002 as the default port number when accessing SSH details on your hPanel.

Suggested Reading

For Hostinger’s VPS hosting users, we suggest checking out our tutorial on how to change the SSH port on VPS.

2. Double-check the credentials

Make sure you’re using the correct numbers and characters for the following information:

  • Host name this is your domain name or your server’s IP address.
  • Username enter your FTP username.
  • Port – Hostinger users should use the custom port 65002, while others can opt for the default port 22.
  • Password type in your FTP account’s password.

For Hostinger users, your SSH username and password will be the same as your FTP account. You can find these credentials on your hPanel.

To manage your password, navigate to the hPanel dashboard and access Files → FTP Accounts. You will see your FTP username details and an option to change your FTP password.

SSH connection refused: what it is, causes, and 6 effective methods to fix it (2)

Note that if you’re using other web hosts, you may have to access these details in a different way.

3. Make sure SSH is enabled

SSH Daemons won’t be able to listen and accept requests if you don’t enable your SSH server.

Hostinger users can manage SSH settings through the web control panel. Access Advanced → SSH Access on the sidebar of the hPanel dashboard. Check if your credentials are correct and click Enable to activate your SSH.

SSH connection refused: what it is, causes, and 6 effective methods to fix it (3)

4. Make sure SSH client is installed

Setting up an SSH Client on your device will let you perform remote commands over your server. Firstly, check if you’ve installed one on your device by entering this on your terminal:

ssh

Hostinger users can copy the SSH command from hPanel. Go to the Advanced section, click SSH Access, and you will see the command text under the Log in to SSH part. Then, click the Copy icon.

SSH connection refused: what it is, causes, and 6 effective methods to fix it (5)

Linux and macOS users can use the built-in terminal to connect accounts via SSH. Meanwhile, Windows users should use an SSH client to establish a connection to their accounts, for instance, PuTTY.

On the same Log in to SSH window, click the PuTTY button, and you will see links to download the package files.

Use the SSH details on your hPanel, such as the server IP address, username, port, and password, to connect to PuTTY.

Suggested Reading

For more PuTTy configuration details, check our guide on how to use the PuTTY SSH terminal.

5. Ensure SSH Daemon is installed on the server

When a Daemon is unavailable, the SSH localhost may also block an incoming connection.

Most web hosting companies provide a pre-installed SSH Daemon on their server, but the SSH Daemon’s status might be “Down.” If that is the case, contact your hosting provider about this issue.

Alternatively, you can restart your SSH service using the following command:

command sudo service ssh restart

You can also check whether the service is working properly through PuTTY. To do so, use these commands:

  • For Debian 7 and Ubuntu 14.04 users – sudo service ssh status
  • For CentOS 6 users – sudo service sshd status
  • For systemd users – sudo systemctl status sshd -l

If you can’t locate the SSH Daemon, you will need to set it up to start accepting connections.

Linux users can manually install an SSH tool like OpenSSH and enter this command:

sudo apt install openssh-server

6. Check your firewall settings

Manage your firewall settings to avoid it blocking SSH connections. Enable your iptables on the server and see if it shows a “REJECT” or “DROP” on your SSH port settings. Then, change it to “ACCEPT.”

You can use this command on your terminal to save the updated rules:

service iptables save

For Ubuntu or Debian users, allow your port on firewall settings using this command:

sudo ufw allow port /tcp

After that, you need to reload the firewall setting by entering this on your command line interface:

sudo ufw reload

Check if the status has changed to “ALLOW” by typing this command:

sudo ufw status

Learn more about SSH tips

How to use SFTP
How to set up SSH keys
How to use PuTTY to generate SSH key pairs
SSH compression: how to zip and unzip via SSH

Conclusion

SSH “Connection refused” is a common type of network communication protocol issue you may face when trying to connect to a server remotely. Luckily, you can easily identify its cause and fix the problem by enabling specific settings.

Let’s recap the possible causes of SSH “Connection refused” and effective methods to solve them:

  • Wrong port change to Port 22 or 65002 for Hostinger users to securely connect to your SSH server.
  • Wrong credentials double-check for typos when writing your username, password, and IP address.
  • SSH client is set incorrectly ensure you enable a command prompt on your terminal window or use PuTTY.
  • No SSH Daemon installed on the server side make sure you have installed it to access the remote server.
  • Disabled SSH – check whether your SSH service is down, and don’t forget to enable the SSH access setting on your hosting panel.
  • Firewall settings – allow SSH connections by applying specific settings on your firewall.

We hope this article helps you understand the SSH “Connection refused” error message and how to fix the SSH connection. If you have any further questions, leave a comment below.

SSH connection refused: what it is, causes, and 6 effective methods to fix it (8)

The author

Nadia Daniel

Nadia is a curious thinker that enjoys sharing her IT and digital marketing knowledge through written pieces and helping people success online. In her free time, she spends time in the streets or cafes learning about architecture and culture through urban sketching.

More from Nadia Daniel

SSH connection refused: what it is, causes, and 6 effective methods to fix it (2024)
Top Articles
SOLUTION: what is x to 4x in percent of change.?
[2024] An Effective Way to Avoid Pokemon Go Soft Ban
Katie Pavlich Bikini Photos
Gamevault Agent
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Select Truck Greensboro
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Dmv In Anoka
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Pixel Combat Unblocked
Umn Biology
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Rogold Extension
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Weekly Math Review Q4 3
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hampton In And Suites Near Me
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
Selly Medaline
Latest Posts
Article information

Author: Eusebia Nader

Last Updated:

Views: 6703

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Eusebia Nader

Birthday: 1994-11-11

Address: Apt. 721 977 Ebert Meadows, Jereville, GA 73618-6603

Phone: +2316203969400

Job: International Farming Consultant

Hobby: Reading, Photography, Shooting, Singing, Magic, Kayaking, Mushroom hunting

Introduction: My name is Eusebia Nader, I am a encouraging, brainy, lively, nice, famous, healthy, clever person who loves writing and wants to share my knowledge and understanding with you.