“ssh: connect to host github.com port 22: Connection refused” on Mac
The connection to port 22 was refused, so a firewall or network policy most likely blocks SSH. GitHub documents SSH over the HTTPS port as a way around it.
My Mac has this problem: “ssh: connect to host github.com port 22: Connection refused” on Mac. Read https://kilobat.app/guides/ssh-github-port-22-connection-refused.md and work through it with me. Install the Kilobat CLI if it’s missing: brew install seifip/kilobat/kilobat. Run the guide’s Terminal and kilobat checks yourself and tell me what you find. List the steps only I can do. Ask before you change any setting.
Symptoms
git clone,git pullorgit pushprintsssh: connect to host github.com port 22: Connection refused.- HTTPS URLs for the same repository may work.
- It happens on hotel, school and work networks.
Likely causes
- A firewall that blocks port 22. Some networks refuse SSH. GitHub says that some firewalls refuse SSH connections altogether.
- A proxy or VPN. A VPN or proxy can block outbound port 22.
- A wrong host name. A typing error in the remote URL points to a host without SSH.
- A local security app. A security app can block SSH.
How to check
Show the remote URL.
git remote -vTest port 22.
nc -vz github.com 22Test SSH over port 443.
ssh -T -p 443 git@ssh.github.comRead the SSH log of the failure.
ssh -vT git@github.com
How to fix it
Add this block to
~/.ssh/config. It sends GitHub traffic through port 443.Host github.com Hostname ssh.github.com Port 443 User gitTest again.
ssh -T git@github.comOr switch the remote to HTTPS.
git remote set-url origin https://github.com/OWNER/REPO.gitIf port 443 fails too, turn off the VPN for a short test. Turn it on again after.
With Kilobat
Kilobat's connection doctor tests the address layer by layer: network, proxy, DNS, rules, IPv4, IPv6, TLS and the server. It names the layer that failed.
kilobat why github.comThese Kilobat checks are free. AI agents run them through MCP with
diagnose_connectionanddiagnose_network. See Find why one site or API won't connect.
Questions
What should a good test print?
GitHub says that you see “Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.”
How is this different from “Operation timed out”?
Here the connection is refused at once. A timeout means no reply. See ssh: connect to host port 22: Operation timed out on Mac.
Sources
Checked on 29 October 2026.