Cloning over SSH fails with "Port 22: Network is Unreachable" error

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.

Cause

  • Verify if the Bitbucket host is accessible on port 22.

1 2 3 4 5 6 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
  • If port 22 is unreachable, it means that their network is blocking the traffic, preventing them from establishing the connection. Consequently, cloning via SSH on this port becomes impossible.

  • Verify the functionality of port 443 by executing the following command.

1 2 3 4 telnet bitbucket.org 443 Trying 18.205.93.0... Connected to bitbucket.org. Escape character is '^]'.
  • If the network permits traffic on port 443, we have the capability to redirect the SSH connection from port 22 to port 443 using altssh host.

Solution

To leverage Bitbucket's altssh host, which operates on port 443 instead of the standard port 22 for SSH connections, simply append the following lines to your ~/.ssh/config file:

1 2 3 4 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 should be able to clone from Bitbucket Cloud using SSH without encountering the "port 22: network is unreachable" error.

Updated on April 16, 2025

Still need help?

The Atlassian Community is here for you.