connect to host localhost port 22: Connection refused

Fix a “ssh: connect to host localhost port 22: Connection refused” error in Ubuntu

I was trying to install hadoop today and part of the setup was being able to ssh to localhost.

So I tried ssh localhost

ssh: connect to host localhost port 22: Connection refused

So googled around a bit; ssh was up and running no problem there.

I tried re-installing it, still no luck.

Came across this 

Checked which port sshd was listening on sudo netstat -tulpen

And what do you know, the port for sshd was not 22

I tried ssh to the said port:

ssh localhost -p 12345

and it worked!

Now I needed to change it:

Use your favorite editor to edit the sshd_config file

sudo nano /etc/ssh/sshd_config

Look for something like

# What ports, IPs and protocols we listen for
Port 12345

And change that port from 12345 to 22

Restart and you’re good to go!

sudo restart ssh

Setting up dbvis for Ubuntu 14.04.1

  1. Download the setup installer from– Open a terminal and cd to the directory where you’ve downloaded the script
  2. sudo bash ./dbvis_unix_<version>.sh and if you get:
  3. No suitable Java Virtual Machine could be found on your system.The version of the JVM must be at least 1.5 and at most 1.7.Please define INSTALL4J_JAVA_HOME to point to a suitable JVM.You can also try to delete the JVM cache file /home/hershel/.install4j

  4. Check your version. I had 1.8 so I needed to install 1.7, refer Installing Java 7 on Ubuntu
  5. sudo update-alternatives —config java
  6. Pick a version between 1.5 and 1.7
  7. Run sudo bash ./dbvis_unix_<version>.sh again. It should work this time 🙂

© 2018 Anna Philips

Theme by Anders NorénUp ↑