Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a server running well before but today I can not ssh to it, it shows me:

ssh: connect to host port 22: Connection refused

I guess something is wrong with it but I can not log onto it so what can I do at this situation, at least to figure out what's the problem with it?

share|improve this question
Did you make any changes and if so what were they ? – Iain Jan 29 '13 at 8:15
try verbose to see whats happening: sudo ssh -vvv -i key.pem user@machine – APZ Jan 29 '13 at 8:27

The Connection refused usually means that there isn't anything listening on the remote port. Did you configure sshd to listen on a different port than the standard one ? If you did then you can use

ssh -p <portnum>

Failing that you will have to access the system by it's console to see if sshd is running and on what port as well as checking logs for additional information.

share|improve this answer

If you have HP iLO, Dell DRAC or SUN ILOM, you can use that to login to server.

share|improve this answer
+1 Always ensure console-level access to a server, that's also why virtual servers are so nice. – Oskar Duveborn Jan 29 '13 at 15:05

1 - Is your ssh running? (as recommended by Ian)

service status sshd

service sshd start (if it is not running)

2 - Check if the port is open (related to (1))

netstat -talpn | grep ":22"

3 - Try temporarily disabling firewall on the ssh client and server, in case outgoing port 22 or incoming port 22 is blocked in either of the machines, respectively.

/sbin/iptables -F

4 - Can you ping the ssh server


share|improve this answer
I did nothing to that server before and I can ping the server. – Mickey Shine Jan 30 '13 at 1:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.