Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

connect to host localhost port 22: Connection refused

Tags:

linux

ssh

hadoop

People also ask

How do I fix connect to host localhost port 22 connection refused?

you need to check the configuration in sshd_config ListenAddress 0.0. 0.0 update this and restart the sshd service that will resolve the issue.

Why is SSH connection refused?

Typos or incorrect credentials are common reasons for a refused SSH connection. Make sure you are not mistyping the username or password. Then, check whether you are using the correct IP address of the server.

How do I restart port 22?

Replace “serverip” with your server's IP address. After executing the script, default port 22 will set on your server. Now, you can log into your server through the port 22 and reset the configuration.


If install Hadoop on Mac OSX, make sure turn on Remote Login under System Preferences then File Sharing. This worked on my machine.

Remote Login


  1. Remove SSH with the following command:

    sudo apt-get remove openssh-client openssh-server
    
  2. Install SSH again with:

    sudo apt-get install openssh-client openssh-server
    

It will solve your problem.


Do you have sshd installed? You can verify that with:

which ssh
which sshd

For detailed information you can visit this link.


Try installing whole SSH package pack:

sudo apt-get install ssh

I had ssh command on my Ubuntu but got the error as you have. After full installation all was resolved.


I use a Mac, this worked for me:

Open System Preferences, then search for 'sharing'.

Choose Remote Login, make sure it is on and remember to add required users.enter image description here

Got it from here


I did all the suggestion above and it did not work. Then I restart the ssh service and it works. This is what I do:

service ssh restart

Then I redo

ssh localhost

Now I can connect to my localhost. Hope it helps


Check if this port is open. Maybe your SSH demon is not running. See if sshd is running. If not, then start it.