Port 22: Connection Refused SSH Error Recently, I signed new keys to gain access to my friend's server. The keys were signed on my friend's machine and I signed and added them to my .ssh folder. I attempted to sign in multiple times but I received an error:

Permission denied (publickey)


This prompted me to try adding multiple keys into my .ssh folder for access to my friend's device. I could get nothing to work. 

I then generated a key pair from my own machine, and I handed it to my friend to add to their server. Soon, I was able to SSH into the server. 

However, the next day, I am receiving an error: 

I'm running MacOS Mojave 10.14.6 on my macbook pro. 

ssh: connect to host [hostname] port 22: Connection refused


I tried uninstalling and reinstalling OpenSSH via Brew, but there was no improvement. Additionally, I tried SSHing over port 2222, which also failed.

Additionally, I tried accessing two different servers and my SSH request failed on both attempts, so it seems a client side issue.

I'm rather new to working in the terminal over mac, so any and all advice would be appreciated. Below is the verbose error log.

ssh -vvv [user]@utdallas.edu

OpenSSH_8.1p1, OpenSSL 1.1.1d  10 Sep 2019
debug1: Reading configuration data /usr/local/etc/ssh/ssh_config
debug2: resolving "utdallas.edu" port 22
debug2: ssh_connect_direct
debug1: Connecting to utdallas.edu [10.182.71.70] port 22.
debug1: connect to address 10.182.71.70 port 22: Connection refused
ssh: connect to host utdallas.edu port 22: Connection refused


Currently, I am receiving a different error, and both seem to be related. 

ssh -vvv ben@67.207.91.101

OpenSSH_8.1p1, OpenSSL 1.1.1d  10 Sep 2019
debug1: Reading configuration data /usr/local/etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname 67.207.91.101 is address
debug2: ssh_connect_direct
debug1: Connecting to 67.207.91.101 [67.207.91.101] port 22.
debug1: connect to address 67.207.91.101 port 22: Operation timed out
ssh: connect to host 67.207.91.101 port 22: Operation timed out


Both servers which I've tried to SSH into are running some form of linux. (I don't have current My friend is still able to access their server from their account, and the school server which I'm attempting to access also allows SSH for other users. Both ports 22 are open on the machines. 

Any diagnostic advice or recommendations for my issue?

Update: I rebooted my Mac, and I ran ssh -vvv [user]@utdallas.edu The first time I tried it it said:

OpenSSH_8.1p1, OpenSSL 1.1.1d  10 Sep 2019
debug1: Reading configuration data /usr/local/etc/ssh/ssh_config
debug2: resolving "utdallas.edu" port 22
ssh: Could not resolve hostname utdallas.edu: nodename nor servname provided, or not known


I ran it again and got a different error. All subsequent errors are of this form.

OpenSSH_8.1p1, OpenSSL 1.1.1d  10 Sep 2019
debug1: Reading configuration data /usr/local/etc/ssh/ssh_config
debug2: resolving "utdallas.edu" port 22
debug2: ssh_connect_direct
debug1: Connecting to utdallas.edu [10.182.71.70] port 22.
debug1: connect to address 10.182.71.70 port 22: Connection refused
ssh: connect to host utdallas.edu port 22: Connection refused
I found the solution to my issue. I was attempting to connect with the wrong hostname.

Bottom line:  Double, no, triple check the hostname you're connecting to.  A lot of these types of issues is caused by innocent, simple mistakes such as this.