Connection Failed
ssh: Could not resolve hostname - Connection refused - Connection timed out - the ssh client cannot reach the git.eu SSH server.
SSH Connection Failed
Symptom
The ssh client cannot reach the server. Each case ends with fatal: Could not read from remote repository.:
ssh: Could not resolve hostname ssh.nonexistent.invalid: Name or service not known
fatal: Could not read from remote repository.
ssh: connect to host 127.0.0.1 port 1: Connection refused
fatal: Could not read from remote repository.
ssh: connect to host 10.255.255.1 port 22: Connection timed out
fatal: Could not read from remote repository.
Cause
Could not resolve hostname: the host name is mistyped, or your DNS does not answer.Connection refused: nothing listens on that host and port. git.eu serves SSH on port 22 only.Connection timed out: a firewall drops the traffic, often an office or public network that blocks outgoing port 22.- Wrong URL form: the scp form
git@host:owner/repo.gittakes no port.git@host:1:owner/repo.gitsilently connects to port 22, not port 1.
Diagnose
1. Show the URL git uses:
git remote -v
The SSH URL has the form git@<host>:<owner>/<repo>.git, as shown on the repository page.
2. Watch the connection (Connecting to ... port 22):
GIT_SSH_COMMAND="ssh -v" git ls-remote origin
Fix
Option A - Fix the URL (recommended)
Copy the SSH clone URL from the repository page and set it:
git remote set-url origin git@ssh.<INSTANCE>.git.eu:<USERNAME>/<REPO>.git
Option B - Use HTTPS on a network that blocks port 22
Switch the remote to HTTPS, with a personal access token: see Clone and Push over HTTPS.
Verify
git ls-remote origin
It lists the branches and tags of the repository.
Prevent
- Copy clone URLs from the repository page instead of typing them.