How To Ubuntu Ubuntu 22.04

How to Fix “Connection Refused By Port 22” On Ubuntu 22.04 LTS

How to Fix “Connection refused by port 22” on Ubuntu
Written by itsubuntu

How to Fix “Connection Refused By Port 22” on Ubuntu 22.04 LTS

Port 22 is used by SSH on Ubuntu for communicating with other machines in the network to transfer data. Port 22 is also used to access the remote system. Meanwhile, this post is for you if you are having the error “Connection refused by port 22” while using port 22. In this post, we will show you the solution for the “Connection refused by port 22” error on Ubuntu.

Before jumping into the solution, let’s have a look at the possible reasons for the “Connection refused by port 22” error on Ubuntu.

Reason For “Connection refused by port 22” error on Ubuntu.

  • The OpenSSH package is not installed on Ubuntu where you are trying to connect.
  • SSH server is not active

 

How to Fix “Connection refused by port 22” on Ubuntu

The most common reason behind this error is  OpenSSH has not being installed on Ubuntu where you are trying to connect.  To see whether OpenSSH is installed or not, run the following command on a remote machine.

sudo apt list --installed | grep openssh-server

If you see nothing printed out on the console, then you do not have it installed. You can easily install OpenSSH using the following command:

sudo apt install openssh-server -y

Now, the issue with port 22 should have been solved. Meanwhile, if you are still having issues then the SSH server might not be active. You can confirm the status of the service of SSH by using the following command:

sudo systemctl status ssh

Now, you can make it active with the following command

sudo systemctl start ssh

About the author

itsubuntu

Leave a Comment