Have you come across the SSH Connection Refused error and become
very confused? What is it? Why are you seeing it in your browser?
SSH or Secure Shell is a network protocol that allows users to
access a remote server. It provides an encrypted and secure connection that
allows users to easily perform several basic and advanced tasks. You can do
everything from running scripts and commands to downloading, uploading, or
editing files. However, this protocol can sometimes run into an error, halting
The SSH Connection Refused error refers to a glitch when the SSH
server does not connect successfully. This is because the SSH server refuses to
form a connection. Therefore, users encounter the “Connection Refused” error
This article will detail all you need to know about the SSH
Connection Refused error, including the error code, error type, and any other
details you are looking for!
What is SSH?
Before diving into the meaning of the error, let’s first know what
When it comes to managing a server, SSH
(Secure Shell or Secure Socket Shell) is one of the most crucial tools at your
SSH is a network protection protocol that
allows effective communication and data sharing between two computers or
- The key aspect of this protocol is that it
offers users, especially administrators, secure access to a computer, even over
an unsecured network. It can also generate secure network tunnels for other
- Secure Shell features some extremely protective
properties that make it so secure. These include strong public key and password
authentication and encrypted data communication between two devices connected
over an open network like the Internet.
- Another prominent use of the SSH protocol by
network administrators is the remote management of systems and applications.
SSH enables them to access another computer remotely, perform tasks, move
files, and execute commands over a network.
- What’s more, SSH is not only a name given to a network protocol. It
also refers to a suite of utilities responsible for executing the protocol.
These utilities comprise the client-server model, which refers to the display
of the session, and the SSH server, the end where the session runs. It often
includes support systems for application protocols to allow seamless file
transfers and terminal emulations.
is an SSH Connection Refused Error?
The SSH Connection Refused error refers to a network communication
protocol failure. The error typically happens when a connection is established
to the SSH server, though unsuccessfully.
SSH connection failure means users or administrators can not perform
the numerous advanced (or basic) tasks they could easily perform using the SSH
protocol. For instance, you will no longer enjoy secure encryptions on your
site or operate remotely executing commands.
The error code associated with the SSH Connection Refused error is ERR_QUIC_PROTOCOL_ERROR.
This will typically occur whenever SSH
protocol fails to establish a successful connection.
SSH Connection Refused is a browser protocol error. However,
you will not face this error on your browser as you visit sites. The SSH
connection occurs between an SSH client installed on your device and an SSH
server program, Daemon, installed on web hosting servers. So, the one place
where the error is likely to appear is the SSH client program.
Connection Refused Error for PuTTY users
PuTTY is an SSH client for Windows. An SSH client is simply a
program installed on your device to establish authenticated, secure, and
encrypted SSH connections with SSH servers. Many clients are available for
various platforms and operating systems, including desktops, servers, and
mobile devices, including WinSCP, Bitvise SSH Client, etc.
When it comes to PuTTY, this program allows users to use their
credentials and establish an SSH connection. However, even as a PuTTY user, you
can encounter the Connection Refused error.
SSH Connection Refused Error for iSSHt Users
iSSHt is a popular SSH client for iOS devices.
With iSSHt, users can establish secure connections to remote servers using
key-based authentication, making it a reliable option for secure remote access.
Like SSH Connection Refused error on puTTy, this error
occurs on iSSHt when the changes in public keys occur.
Causes of SSH Connection Refused Error
There are several reasons why users may face the SSH Connection
Refused error, including the following.
Disabled SSH Services
Connecting to a server via SSH is a critical
aspect of server administration. However, if your SSH daemon is disabled or
down, your server won't be able to accept incoming SSH connections, leading to
one common error, the “SSH Connection refused” message.
This can be a
frustrating experience for server administrators, especially when it's unclear
what caused the issue. The reasons for this can vary, including traffic surges,
resource outages, or even DDoS attacks.
If the server is
experiencing high traffic, it might be possible to refuse to connect with the
incoming requests. In that case, the connection request is denied resulting in
an SSH connection refused message on your browser. Connecting at an alternative
time may help resolve the issue.
Missing SSH Daemon on Server
An SSH daemon, also known as sshd, is a program that runs on the
server side and listens for incoming SSH connections on a specific port. When a user attempts to
connect to a remote server using an SSH client, your device sends a connection
request to the server's SSH daemon, which listens on a specific port for
If the SSH daemon is not installed or not running on the server,
users attempting to establish an SSH connection will receive an SSH Connection
Missing SSH Client
If the SSH client is not installed on your
device, it cannot send a connection request to the server, resulting in an SSH
Connection refused error. This error indicates that the server's SSH daemon did
not receive a connection request from the SSH client because the client was not
installed or configured correctly.
You are directed
to a specific endpoint or port when connecting to a server. If the ports are
left open, they can pose a security threat, as attackers can use them to
infiltrate your system.
To prevent this,
administrators often close unused ports on the server. However, this can also
cause the SSH Connection refused error, especially if the default port (22) or
a custom SSH port is closed.
Wrong SSH Port
An incorrect SSH port can cause an SSH
connection refused error. SSH has assigned a default port number, 22, for
So, if the port number
is altered to a different number, and you try to send the connection request to
port 22, it will refuse to connect. It’s because no service is running to
develop a connection to the SSH server resulting in the connection refused error.
Incorrect Login Credentials
When a user attempts to log in to an SSH server, the server
first verifies the user's credentials, such as the username and password. If
the user repeatedly enters incorrect details, the server may interpret these
attempts as unauthorized login attempts, resulting in the Connection refused
The Firewall Interference
Installing firewalls is
a common security measure to monitor and control incoming and outgoing network
traffic and safeguard servers against malicious attacks. However, firewall
settings can also inadvertently hinder users' access to their servers by blocking
connections to open ports, including the port used by SSH (port 22 by default),
resulting in a frustrating Connection refused error message.
in Public Keys
SSH connections use public key cryptography to
authenticate the client and server and establish a secure connection. Each SSH
client and server has a unique public key, which is used to verify their
identities and encrypt the communication between them.
uninstall and reinstall iSSHt, the SSH client generates a new set of public and
private keys. If these new keys do not match the public key stored on the
remote server, the server will reject the connection, resulting in an SSH
Connection refused error.
Troubleshooting Hacks for SSH Connection Refused Error
With several causes at play, fortunately, there are solutions as
well. So, there is nothing to stress about; you can fix this error. Whether you
are using PuTTY, iSSHt, or whatever the cause is, there are troubleshooting
solutions to ensure a successful connection.
Here are a few ways to address and fix the SSH Connection Refused
1. Enable the SSH Service
If the SSH service
is down, disabled or not running, the server rejects the connection request
from the SSH client. This would result in an SSH connection refused error. To
fix this, ensure the SSH service is enabled and running smoothly.
the error, checking the status of the SSH server program is crucial. Run the
following command in localhost to check the status of the SSH service.
$ systemctl status sshd
If the server is
down and you use dedicated hosting, you may run the following command to start
the SSH service.
Run the following
command to enable the service.
If the error is
still there, you need to reboot the server.
spikes may overload the server with connection requests. This would result in a
connection refused error from the ssh server side. To fix this issue, you need
to restart the server.
following command to reboot the SSH server and execute the browsing process
without facing the error.
If rebooting the
server doesn’t work, you should apply the next fix.
3. Install the SSH Daemon
If the SSH Daemon is missing, the connection
from the local host will be blocked. You should ensure the SSH daemon is
installed and running on the server. You can start it manually or configure it
to start automatically upon server boot.
You can check if the SSH is running on your
device by running the following command.
ssh local host
To check if SSH is available on
a remote server, you would need to use a similar command, replacing localhost
with the hostname or IP address of the remote server, For example
If it is not installed, you will see the
Installing SSH Daemon
The hosting companies provide SSH installed on
the server by default. If it is not installed, contact your hosting provider's
support team. They can check the status of the SSH service and provide you with
If you manage your dedicated server or local
host and SSH, users must install it on the server and start the daemon. The
installation process will vary depending on the server's operating system but
typically involves running a package manager command to install the OpenSSH
You can run the following command to install SSH
on the server using openSSH.
sudo apt install openssh-server
Checking Daemon Configuration
If installed, you can check the server's SSH
configuration file, usually located at /etc/ssh/sshd_config, to verify
that the SSH daemon is configured correctly and is set to start automatically
when the server boots up.
You can enter
the following commands for the devices you are using to check the configuration
of SSH Daemon.
- CentOS 6 users: sudo service sshd status
- Debian 7 and Ubuntu 14.04 users: sudo service ssh status
- systemd users (Arch, Ubuntu 16.04+, Debian 8+, CentOS 7+, etc): sudo systemctl status sshd -l
doesn’t work, you can check the status of the SSH client on your local machine.
4. Install the SSH Client
Without a properly configured SSH client, users
may encounter a Connection refused error when connecting to the server. Ensure
the SSH client is installed on your local machine to fix the error.
You can check the status of the SSH client by
entering the following command in the terminal or command prompt.
The list of commands will be shown if the SSH
client is running, However, if the command is not recognized, it will show “Command
not found.” In that case, you must install an SSH client compatible with
your operating system. The installation process may vary for the host and the
For Mac, there is a default SSH client is
installed, so you do not have to do so manually.
You may need to run the specific commands to
install on Linux using the openSSH.
Run the following
command to install the SSH client on Ubuntu.
Run the following
command to install the SSH client on CentOS.
A closed port may cause the SSH connection
refused error. To fix it, check if all ports listen to the connection requests.
For this, enter the following command.
sudo lsof -i -n -P | grep LISTEN
If you see the status of ports as LISTEN,
it means the port is open. You can find port 22 (default port) from the list or
run the following command for it specifically.
sudo lsof -i:22
If the port is closed, you must open it to
accept the connection requests. To open the port, execute the following
iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j
An incorrect port number may cause the
connection refused error. Specify the port number if it is incorrect when
connecting to the server. Alternatively, you can update the SSH configuration
file on your machine to use the correct port number by default.
configuration file is usually located at /.ssh/config and can be edited
using a text editor with the following steps.
in as an admin on the server.
the configuration file sshd_config.
the text editor. vi /etc/ssh/sshd_config
- Locate the default port 22
and change its entry with another port number.
Once you have specified the correct port number,
you should be able to connect to the SSH server without any connection refused
crosscheck the login credentials if this method does not fix the error.
7. Verify the Login Credentials
Brute force attacks involve systematically
guessing the username and password combinations until the correct ones are
found, which can be time-consuming but ultimately successful.
So, if this happens, the dreaded connection refused error
message is shown on your browser means the SSH server is trying to prevent
unauthorized access and protect the system from malicious attacks. Basically,
the SSH connection refused error acts as a security feature that helps prevent
brute-force attacks on the server.
- To connect to an SSH server, you must provide the correct credentials, including the hostname, SSH username, and password.
Hostname: It is the address of the server you are trying to connect to. This can be an IP address, a server name, or a domain name pointing to the server's IP address using an A record.
SSH username: The username for the SSH server you are trying to access. This username must be valid and have permission to access the server.
Password: The password for your private SSH key is used for authentication instead of a traditional password. If you enter an incorrect passphrase, the server will refuse your connection.
- Keeping your credentials up-to-date and secure is important to prevent SSH connection errors.
- You should also consider using a strong passphrase for your private SSH key and regularly updating it.
- Additionally, you can set up two-factor authentication to provide an extra layer of security for your SSH connections involving generating a public and private key pair and using them to authenticate instead of a password.
You can run the following
command to see if you have entered the wrong credentials.
grep Port /etc/ssh/sshd_config
If you want to change the password, you can do so by the following
- Go to hPanel.
- Click on Hosting from the sidebar.
- Click Files > FTP Accounts.
- Click Change your FTP password.
- Make changes and save
For different web hosts, the
steps may vary.
7. Disable Firewall Settings
If you are experiencing an SSH
connection refused error, it might be possible that your firewall may be
interfering with the SSH connection.
To fix this error, you can
manage your firewall settings. If you see the iptables settings as Reject or
Drop, you must enable iptables on the server and update the SSH port
settings to ACCEPT. This can be done by running a simple command on your
service iptables save
For Ubuntu or Debian users, you
can allow the port on the firewall settings using this command:
sudo ufw allow port/tcp
Once you have made these
changes, you will need to reload the firewall settings by entering this on your
command line interface:
sudo ufw reload
Finally, you can check the
status of the firewall settings by typing this command:
sudo ufw status
This will help you to determine
if the status has changed to ALLOW for your SSH connections.
To prevent SSH connection
refused errors from happening, it's crucial to monitor your server's resources
and traffic regularly. You can also implement measures such as rate limiting
and disabling firewalls to prevent DDoS attacks and other malicious traffic.
8. Update the Public Keys
If you uninstall and reinstall iSSHt, it may generate a new SSH key
pair, including a new public key. If this new public key is not updated on the
remote server, it can cause the SSH connection refused error.
- To resolve this issue, you will need to update the public key on the remote server to match the new public key generated by iSSHt. This can typically be done by logging into the server and updating the authorized_keys file in the user's .ssh directory with the new public key.
- Alternatively, you can regenerate the SSH keys on the server to match the new public key generated by iSSHt. However, this may also require updating the public key on other clients that connect to the server.
Contact Hosting Provider
Following the abovementioned steps and being
proactive about monitoring your server's resources and traffic can minimise the
likelihood of encountering SSH Connection refused error and ensure a smoother
If none of
these steps works, the issue may lie with your hosting provider. Contact their
support team to see if there are any known issues with the SSH service on your
SSh or Secure Shell is a network communication protocol that allows
users a safe, secure, and encrypted server connection over open networks.
However, failure to connect to an SSH server can result in the SSH Connection
The error happens due to various reasons, including disabled SSH
services, firewall blocking SSH connection, SSh Client not installed on your
device, misconfigured SSH port settings, repeated attempts to log in with
incorrect credentials, etc.
Fortunately, there are several troubleshooting hacks to get over
this error! You can re-configure the Firewall settings to stop it from blocking
the SSH connection, ensure SSH Daemon is successfully installed, check to see
SSh is enabled, double-check the credentials, etc. If all else fails, don't
hesitate to contact your hosting provider's support team for assistance.
The SSH Connection
Refused error may be annoying. However, it is not very difficult to tackle. So,
if you ever encounter or re-encounter this error, you can refer to this article
and find everything to know about the SSH Connection Refused error!
Do I Fix SSH Connection Refused Error?
You can fix the
SSH connection refused error by enabling the SSH service, installing the SSH
Daemon or the SSH client, enabling the port settings, checking the firewall
settings, and verifying the login credentials. You may also fix this error for
iSSTh users by updating the public keys.
Causes SSH Connection Refused Error?
refused is caused when the server does not accept the request from the SSh
client. This can happen for many reasons, including if the SSH service is down
or disabled, the SSH daemon or SSH client is not installed, or incorrect or
closed port settings. Login credentials of the server or the firewall settings
can also be the culprit for this error.
is SSH not running on Port 22?
Sometimes due to
security concerns, port 22 (default port) is closed if it is not used for a
long time. It is because the open ports are potentially more vulnerable to
does port 22 connection refused mean?
Port 22 Connection
refused means port 22 is not enabled to listen to the connection requests sent
from the SSH client to the SSH Daemon server. This can happen if the SSH
service os disabled, the SSH client is not installed, or some other credentials
to change port 22 for SSH?
To change port 22
for SSH, log in to the server as an admin, open the configuration file in the
editor sshd_config in the editor, and change port 22 to
another port number.