fix no route to host ssh error

How to Fix ‘No Route to Host’ SSH Error in Linux

SSH (Secure Shell) allows you to securely connect to remote servers. It is often used by developers and system administrators while working in Linux as well as other operating systems. While using SSH, one of the most common errors people face is ‘No route to host’. In this article, we will learn how to fix ‘no route to host’ SSH error in Linux.

How to Fix ‘No Route to Host’ SSH Error in Linux

Here are the steps to fix this issue.

One of the most common reasons why this error occurs is because the remote server is down. So the first thing you can do is to check if the remote server is up & running. You can use tools like ping command for this purpose. Here is the syntax for ping command.

$ ping remote_ip_address

For example, if is your remote server’s IP address then here is the command to check if it is up & running.

$ ping

If the ping command returns proper output and indicates that the server is up and running, then it may be that the firewall on your remote server is blocking the incoming SSH connection attempt on port 22, ow whichever port you are connect to. In such cases, log into your remote server’s terminal (without SSH) and run the following commands.

## centos/rhel/fedora/suse systems
# firewall-cmd --permanent --add-port=22/tcp
# firewall-cmd --reload

## ubuntu/debian systems
$ sudo ufw allow 22/tcp
$ sudo ufw reload 

If you are using another port on remote server to run SSH service, then replace 22 with that port number. Once that is done, try connecting again to your remote SSH server. Replace username below with your SSH username and remote_ip_address with your remote server’s IP address.

$ ssh username@remote_ip_address

In this article, we have learnt how to fix ‘No Route to Host’ SSH error in Linux. Basically, this error occurs because the remote server is not allowing incoming connections, either because it is down or because of firewall problems.

Also read:

How to Find Django Install Location
Xargs Command to Kill Process
How to Enable Full Disk Encryption in Linux
How to Insert Item into JS Array At Specific Index
How to Find Files Larger Than 100Mb

Leave a Reply

Your email address will not be published. Required fields are marked *