didit
By:
didit

connect to host 128.xxx.xxx.xx port 22: Connection refused

September 15, 2014 59.8k views

Hello, I am new in using Digital Ocean Cloud server
I am using ubuntu 14.04 for host my multiple site. Firstly, I success for ssh connection.
Then I installed My SQL, Phpmyadmin, apache and secure them using this way :
https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-14-04
and,
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-14-04

I logged out, then tried to access again with ssh connection and I got :
ssh: connect to host 128.199.xxx.xx port 22: Connection refused.

I am using Ubuntu 14.04 in my dekstop.

Can anyone help me ?

3 comments
5 Answers

Is your server even running ?
Are you able to ping to your server IP ?
Seems the SSHD service is shut down for some reason.
A reboot to the server might help.

Should I reboot my server through console ? I think it will cause my data corrupt.
When I ping it. It works, and when I access it show me apache default page.

  • You can try starting the ssh server:

    sudo service ssh start
    
  • I tried to reboot my server, the run following command :
    sudo service ssh start

    I got : " ssh stop/waiting"

    I tried again with : "sudo service ssh restart"
    I got : "stop : unknown instance "

  • It looks like ssh failed to start, are there any errors in /var/log/syslog?

    sudo tail -50 /var/log/syslog /var/log/auth.log
    
  • I got :
    tail : option used in invalid context --5

  • There should be one dash only, not two, so replace --50 with -50. Does that work?

  • I tried both "--50" and "-50".
    And I got the same error messege.

  • Can you post the exact command that you're running?

  • sudo tail -50 /var/log/syslog /var/log/auth.log
    I got : tail : option used in invalid context --5

    Then
    sudo tail --50 /var/log/syslog /var/log/auth.log
    tail : unrecognized option "--50"
    try "tail --help" for more information

  • I tried :
    sudo apt-get install openssh-server
    sudo apt-get install openssh-client

    /etc/init.d/ssh start
    
    sudo service ssh status
    

    It works, now everything is okay.

    Thank you for helping me.

Check your ports, run:

nano /etc/ssh/sshd_config

or

vi /etc/ssh/sshd_config

and you should see:

Port: 22

If it's not "22", but something like "2345", then adjust your connection line. In Linux or OSX:

ssh -p 2345 your_username@your_droplets_ip_address
ssh -p 2345 root@123.123.123.123
Have another answer? Share your knowledge.