---
title: "ssh: connect to host port 22: Operation timed out on Mac · Kilobat Guides"
url: "https://kilobat.app/guides/ssh-port-22-operation-timed-out.html"
description: "ssh on your Mac says connect to host port 22: Operation timed out. Find whether the network blocks SSH, then use port 443 for GitHub or fix IPv6."
---

Error messages

# ssh: connect to host port 22: Operation timed out on Mac

ssh sent a connection request to port 22 and got no answer. On a Mac, the system error text is “Operation timed out”. Linux says “Connection timed out”.

Applies to: The OpenSSH that comes with macOS, on all current versions. The text was checked with OpenSSH 10.5 on macOS 27.2. · Checked: 29 October 2026

## Symptoms

- Terminal shows `ssh: connect to host github.com port 22: Operation timed out`.
- Git then shows `fatal: Could not read from remote repository.`
- SSH works on another network, such as your home network.

## Likely causes

- **The network blocks port 22.** Company, school, hotel and public networks often block SSH. GitHub says that firewalls sometimes refuse SSH connections.
- **A broken IPv6 path.** The Mac tries IPv6 first, and IPv6 does not work.
- **A VPN or proxy.** Traffic goes through a VPN that does not pass SSH.
- **The server is down or filtered.** The server does not answer on port 22.

## How to check

1. Test the TCP port alone, with a 5-second timeout.

   ```
   nc -vz -G 5 github.com 22
   ```
2. Try IPv4 only.

   ```
   ssh -4 -T git@github.com
   ```
3. For GitHub, test SSH on port 443.

   ```
   ssh -T -p 443 git@ssh.github.com
   ```
4. Connect with details. The last lines show where it stops.

   ```
   ssh -vT git@github.com
   ```

## How to fix it

1. If port 443 works, use it for GitHub. Add this block to `~/.ssh/config`.

   ```
   Host github.com
       Hostname ssh.github.com
       Port 443
       User git
   ```
2. If only IPv4 works, add `AddressFamily inet` to the host's block in `~/.ssh/config`.
3. Use the HTTPS URL of the repository instead, as a test.
4. For your own server, ask the network administrator to allow its SSH port.

## With Kilobat

1. Kilobat's connection doctor tests the host layer by layer: network, proxy, DNS, rules, IPv4, IPv6, TLS and the server. It names the layer that failed.

   ```
   kilobat why github.com
   ```
2. These Kilobat checks are free. AI agents run them through MCP with `diagnose_connection` and `diagnose_network`. See [Find why one site or API won't connect](https://kilobat.app/guides/recipes/why-cant-it-connect.html).

## Questions

**Why does my Mac say Operation timed out, not Connection timed out?**

ssh prints the system's text for the error. On macOS, the text for ETIMEDOUT is “Operation timed out”.

## Sources

- [GitHub Docs: Using SSH over the HTTPS port](https://docs.github.com/en/authentication/troubleshooting-ssh/using-ssh-over-the-https-port)
- ssh(1), ssh_config(5) and nc(1), man page installed with macOS 27.2
- intro(2), ETIMEDOUT, man page installed with macOS 27.2

Sources checked on 29 October 2026. Man pages are the ones installed with macOS; open one with `man <name>` in Terminal.

## Related guides

- [SSH and Git time out on a Mac](https://kilobat.app/guides/ssh-git-timeouts.html): SSH and Git need a working TCP connection to the server.
- [Git: “Could not resolve host: github.com” on Mac](https://kilobat.app/guides/git-could-not-resolve-host-github.html): Git could not get an address for github.com.
- [IPv6 problems on a Mac](https://kilobat.app/guides/ipv6-problems-mac.html): Most networks give a Mac both IPv4 and IPv6 addresses.
- [Corporate proxy certificates break Terminal tools on a Mac](https://kilobat.app/guides/corporate-proxy-certificates.html): Some company networks inspect HTTPS traffic.
