Periodic Connection Refused when making Git push requests with SourceTree
Asked by mgrimard:

I often have frequent periods of 1-5 minutes where my connection with Git will fail. When this happens I have to wait several minutes before it 'resets' and lets me do my push or pull.

This is the error that I get:

Pushing to [bitbucket.org](https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fbitbucket.org&c=E,1,tdEEjU5SV2-h36XOZmv52IKE4yvZWL29N8eqxEWeUITLShsMt9KMke4YWp5X1iWHJA5q8vRLlHZ_53YDdQFiti3rgCWaENPp5ZO0ogwhn-H0K_FibYwoE6I,&typo=1):\<WORKSPACE\>/\<REPOSITORY\>.git  
ssh: connect to host [bitbucket.org](https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fbitbucket.org&c=E,1,N_fNl603yEXZZ9Vi23aOGUl9XQTwviuSMvlc2efNODGByM_WFld74HFY2CMMt-93m8HczDNqRNWiEKT5J5NgMUF4THpkpE3egkeOl6TZllck_A,,&typo=1) port 22: Connection refused  
fatal: Could not read from remote repository.  
I have tried switching my ssh config to use 443, but the same issue occurs.  
My systems team says it is not a firewall issue and has asked me to reach out to bitbucket.  
Any help would be appreciated.


Answers:
author: Patrik S
body: Hello [@mgrimard](/t5/user/viewprofilepage/user-id/941593) ,

Thank you for reaching out to Atlassian Community!

This is usually related to firewall/proxy blocking the connection. Could you check if the all following IPs are whitelisted in your company's firewall?

* <https://support.atlassian.com/bitbucket-cloud/docs/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall/>

If that does not work, as you said it's intermittent, the next time you face the error could you please run the following command in your terminal to clone the repository to another folder and share the output?

```
GIT_TRACE_PACKET=1 GIT_TRACE=1 GIT_SSH_COMMAND="ssh -vvv" git clone git@bitbucket.org:<workspace>/<repository>.git
```

This will give us verbose loggings of the SSH connection and hopefully bring us more details on what is causing the issue.

Thank you, [@mgrimard](/t5/user/viewprofilepage/user-id/941593) .

Kind regards,

Patrik S

comments: author: mgrimard
body: Hey Patrik,

Here is a git clone command that you asked for during a period when the issue was happening -

```
? files git:(main) GIT_TRACE_PACKET=1 GIT_TRACE=1 GIT_SSH_COMMAND="ssh -vvv" git clone git@bitbucket.org:kfpl-site-admin/developers-handbook.git
10:14:38.468473 exec-cmd.c:139 trace: resolved executable path from Darwin stack: /Library/Developer/CommandLineTools/usr/bin/git
10:14:38.470157 exec-cmd.c:238 trace: resolved executable dir: /Library/Developer/CommandLineTools/usr/bin
10:14:38.477236 git.c:455 trace: built-in: git clone git@bitbucket.org:kfpl-site-admin/developers-handbook.git
Cloning into 'developers-handbook'...
10:14:38.517963 run-command.c:667 trace: run_command: unset GIT_DIR; GIT_PROTOCOL=version=2 'ssh -vvv' -o SendEnv=GIT_PROTOCOL git@bitbucket.org 'git-upload-pack '\''kfpl-site-admin/developers-handbook.git'\'''
OpenSSH_8.6p1, LibreSSL 3.3.6
debug1: Reading configuration data /Users/mgrimard/.ssh/config
debug1: /Users/mgrimard/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/mgrimard/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/mgrimard/.ssh/known_hosts2'
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to bitbucket.org port 22.
ssh: connect to host bitbucket.org port 22: Connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
```


Tags: bitbucket-cloud

cloud