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.

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

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