---
title: "SSH and git push time out on Mac: causes and fixes · Kilobat Guides"
url: "https://kilobat.app/guides/ssh-git-timeouts"
description: "Fix SSH and Git connections that hang or time out: test port 22, use SSH over port 443 for GitHub, set keepalives and check IPv6 and proxies."
---

Developers

# SSH and Git time out on a Mac

SSH and Git need a working TCP connection to the server. A network that blocks port 22, a broken IPv6 path or a proxy can stop them.

Applies to: All current macOS versions with the OpenSSH and Git that macOS or Homebrew installs. · Checked: 29 October 2026

## Symptoms

- `git push` or `git clone` waits, then shows “Operation timed out”.
- `ssh` shows “Connection timed out” on one network but works on another.
- An SSH session freezes after some idle minutes.
- HTTPS Git remotes work, but SSH remotes do not.

## Likely causes

- **Port 22 is blocked.** Some company, hotel and public networks block SSH. GitHub says that firewalls sometimes refuse SSH connections.
- **A broken IPv6 path.** The Mac tries IPv6 first. If IPv6 does not work, the connection waits.
- **Idle connections close.** A router or firewall can drop a connection that sends no data for some time.
- **A proxy is necessary.** HTTPS Git on a company network can need `http.proxy` or proxy variables.

## How to check

1. Connect with verbose output. The last lines show where the connection stops.

   ```
   ssh -vT git@github.com
   ```
2. Test the TCP port alone, with a 5-second timeout.

   ```
   nc -vz -G 5 github.com 22
   ```
3. Try IPv4 only. If this works, the IPv6 path is the problem.

   ```
   ssh -4 -T git@github.com
   ```
4. Test GitHub's SSH service on port 443.

   ```
   ssh -T -p 443 git@ssh.github.com
   ```
5. Show Git's proxy setting and your proxy variables.

   ```
   git config --get http.proxy
   env | grep -i proxy
   ```

## How to fix it

1. If port 22 is blocked, use SSH over port 443 for GitHub. Add this block to `~/.ssh/config`.

   ```
   Host github.com
       Hostname ssh.github.com
       Port 443
       User git
   ```
2. If IPv6 fails, use IPv4 for that host. Add `AddressFamily inet` to its block in `~/.ssh/config`.
3. To keep idle sessions open, send a message every 60 seconds. Add `ServerAliveInterval 60` to the host block.
4. To stop long waits, add `ConnectTimeout 10` to the host block.
5. For HTTPS remotes behind a proxy, set Git's proxy.

   ```
   git config --global http.proxy http://proxy.example.com:8080
   ```
6. As a test, use the HTTPS URL of the repository instead of the SSH URL.

## With Kilobat

1. Kilobat's connection check tests IPv4 and IPv6 separately, so a broken IPv6 path gets a clear answer.

   ```
   kilobat why github.com
   ```
2. See the open connections of one process.

   ```
   kilobat destinations --pid 12345
   ```

## Questions

**Why does ssh -4 work when plain ssh does not?**

The Mac tried IPv6 first, and the IPv6 path did not work. With `-4`, ssh uses IPv4 only.

**What does ServerAliveInterval do?**

ssh sends a message through the connection after that many seconds without data. The default is 0, which sends none.

## 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) and ssh_config(5), man page installed with macOS 27.2
- nc(1), man page installed with macOS 27.2
- git-config(1), http.proxy, man page installed with macOS 27.2 (Git 2.56)

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

## Related guides

- [IPv6 problems on a Mac](https://kilobat.app/guides/ipv6-problems-mac): 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): Some company networks inspect HTTPS traffic.
- [Homebrew or npm downloads fail on a Mac](https://kilobat.app/guides/homebrew-npm-download-fails): Homebrew downloads with curl and Git.
- [Find why one site or API won't connect](https://kilobat.app/guides/recipes/why-cant-it-connect): When the internet works but one address fails, Kilobat checks each layer in turn.
- [ssh: connect to host port 22: Operation timed out on Mac](https://kilobat.app/guides/ssh-port-22-operation-timed-out): ssh sent a connection request to port 22 and got no answer.
