bitbucket connect get stuck or timeout
Asked by allen:

I often encounter connectivity issues when fetching repositories from Bitbucket. The connection often gets stuck and requires multiple retries, with a failure rate exceeding 50%. When a successful connection is made, I receive the message:

    **Warning: Permanently added 'bitbucket.org,104.192.141.1' (ECDSA) to the list of known hosts.**

However, when the connection fails, no error message is displayed, and it remains stuck indefinitely. This issue significantly impacts my work, and I'm experiencing quite a bit of frustration.

**Scenario 1** : I encounter this issue when performing Git operations, such as **`git pull origin test`**.

**Scenario 2**: I face this problem when running Ansible to fetch repositories from Bitbucket. I need to fetch four repositories in succession, which makes it prone to failures, ultimately preventing me from executing my tasks.

**SSH Configuration**:

My SSH configuration for Bitbucket is as follows:

    bashCopy codeHost bitbucket.org  AddKeysToAgent yes  IdentityFile ~/.ssh/bitbucket_work

**Validation Files**:

I have both **`bitbucket_work.pub`** and **`bitbucket_work`** as relevant authentication files.

I have also executed **`ssh -Tv git@bitbucket.org`**, and sometimes it succeeds, while other times it gets stuck at the following point:

    OpenSSH_8.2p1 Ubuntu-4ubuntu0.5, OpenSSL 1.1.1f  31 Mar 2020debug1: Reading configuration data /home/allen/.ssh/configdebug1: Reading configuration data /home/allen/.ssh/kapitoai/configdebug1: /home/allen/.ssh/config line 3: Applying options for bitbucket.orgdebug1: Reading configuration data /etc/ssh/ssh_configdebug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no filesdebug1: /etc/ssh/ssh_config line 21: Applying options for *debug1: Connecting to bitbucket.org [199.19.56.1] port 22.

Your assistance in resolving this matter would be greatly appreciated. Thank you.


Answers:
author: Patrik S
body: Hello [@allen](/t5/user/viewprofilepage/user-id/5315316) and welcome to the Community!

From the looks of it, it sounds like a DNS resolution issue as the IP address the debug log is showing when you mentioned it failed and got stuck is not a [Valid bitbucket.org IP address](https://support.atlassian.com/bitbucket-cloud/docs/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall/).

In this case, I would suggest changing your DNS to a different one and check if there's any improvement. You can try using Google's DNS 8.8.8.8

Alternatively, you can temporarily change your machine's host file to force the resolution of bitbucket.org to a fixed address. For this, you will need to edit the **/etc/hosts**file and include the following entry :

```
104.192.141.1 bitbucket.org
```

Although we don't expect that IP to be changed, it's safer to let your DNS server resolve the IP address, but forcing it on the hosts file might be a temporary solution.

Thank you, [@allen](/t5/user/viewprofilepage/user-id/5315316) !

Patrik S

comments: author: allen
body: Thank you for your help!

After making the following changes, although "104.192.141.1 [bitbucket.org](http://bitbucket.org)" still appears, the current connection no longer gets stuck. Here are the actions I took:

    sudo vim /etc/hosts104.192.141.1   bitbucket.orgsudo vim /etc/resolv.conf:nameserver 8.8.8.8sudo vim /etc/wsl.conf:[network] generateHosts = false

Do these actions meet expectations? I would like to inquire if there are any missing configurations or additional changes needed.


Tags: bitbucket-cloud

cloud

error