Cloning over SSH fails with error "Port 22: Network is Unreachable" in Bitbucket Cloud
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
This KB article addresses the "port 22: network is unreachable" error that occurs when trying to clone from Bitbucket Cloud using SSH.
Diagnosis
SSH clone output shows the following:
telnet bitbucket.org 22
Trying 18.205.93.0...
Trying 18.205.93.1...
Trying 18.205.93.2...
Trying 2406:da00:ff00::22cd:e0db...
telnet: Unable to connect to remote host: Network is unreachable
Cause
Possible causes for this error are:
Port 22 is being blocked on your network.
There is a firewall blocking outbound connections.
There is some other misconfiguration in your network.
Solution
Verify the functionality of port 443 by executing the following command from a terminal:
telnet bitbucket.org 443
If the output of this command reads "Connected to bitbucket.org," then your network permits traffic on port 443, and we can redirect the SSH connection from port 22 to port 443 using altssh host.
telnet bitbucket.org 443 Trying 18.205.93.0... Connected to bitbucket.org. Escape character is '^]'.
To leverage Bitbucket's altssh host, which operates on port 443 instead of the standard port 22 for SSH connections, append the following lines to your ~/.ssh/config
file:
Host bitbucket.org
Hostname altssh.bitbucket.org
IdentityFile ~/.ssh/id_rsa
Port 443
~/.ssh/id_rsa
is the path to your private SSH key file, this might vary depending on where you store the keys on your machine. The corresponding public keys should be added to bitbucket.org as per our Configure SSH documentation.
After implementing these changes, you can clone from Bitbucket Cloud using SSH without encountering the "port 22: network is unreachable" error.
If the output of telnet bitbucket.org 443 shows an error message like telnet: Unable to connect to remote host: Network is unreachable, the most likely reason is that a firewall or some network misconfiguration is blocking your connection to Bitbucket Cloud.
We recommend reaching out to your network administrator and asking them to check for any issues with your network. If there is a firewall allowing outbound connections only to specific IP addresses, you can find Bitbucket Cloud's IP addresses on this page: IP addresses and domains to allowlist in your corporate firewall.
Was this helpful?