When attempting to execute a git push operation, the process fails and returns the error message 'Could not read from remote repository' on Bitbucket Data Center

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

While attempting to execute the git push operation, SSH connections are getting dropped with the "Could not read from remote repository" error message.

Environment

Applied to Bitbucket Data Center 7.10.0
Applies to Bitbucket Data Center 7.x and 8.x

Diagnosis

Enabled Git client debugging to get more details using the below steps:

For HTTP/HTTPS URL:
On Linux:

export GIT_TRACE_PACKET=1
export GIT_TRACE=1
export GIT_CURL_VERBOSE=1

On Windows:

set GIT_TRACE_PACKET=1
set GIT_TRACE=1
set GIT_CURL_VERBOSE=1
For SSH URL:

a. Set the following variable for the ssh debug log: GIT_SSH_COMMAND="ssh -vvv" 
b. Replicate the issue for example: git clone ssh://git@<bitbucket URL>:<bitbucket port>/<project key>/<repository slug>.git


Cause

This issue generally occurs when the SSH connection is closed by remote host.
The git client debug output below indicates that the connection for git push operation is closed by the Remote Host and it has been closed on port 22.

Click here to expand...

C:\projects\ >git push
OpenSSH_8.8p1, OpenSSL 1.1.1l 24 Aug 2021
debug1: Reading configuration data /c/Users/Pxxxxxxx/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to xxxxxxxxxxxxx [xx.xx.x.xx] port 22.
debug1: Connection established.
debug1: identity file /c/Users/Pxxxxxx/.ssh/id_rsa type 0
debug1: identity file /c/Users/Pxxxxxx/.ssh/id_rsa-cert type -1
debug1: identity file /c/Users/Pxxxxxx/.ssh/id_dsa type -1
debug1: identity file /c/Users/Pxxxxxx/.ssh/id_dsa-cert type -1
debug1: identity file /c/Users/Pxxxxxx/.ssh/id_ecdsa type -1
debug1: identity file /c/Users/Pxxxxxx/.ssh/id_ecdsa-cert type -1
debug1: identity file /c/Users/Pxxxxxx/.ssh/id_ecdsa_sk type -1
debug1: identity file /c/Users/Pxxxxxx/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /c/Users/Pxxxxxx/.ssh/id_ed25519 type 3
debug1: identity file /c/Users/Pxxxxxx/.ssh/id_ed25519-cert type -1
debug1: identity file /c/Users/Pxxxxxx/.ssh/id_ed25519_sk type -1
debug1: identity file /c/Users/Pxxxxxx/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /c/Users/Pxxxxxx/.ssh/id_xmss type -1
debug1: identity file /c/Users/Pxxxxxx/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.8
kex_exchange_identification: Connection closed by remote host
Connection closed by xx.xx.x.xx port 22
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.


Typically, connectivity is expected to occur through port 7999 for SSH connections. However, specifying port 22 suggests that a Load Balancer has been set up for the Bitbucket environment. Under this configuration, requests from the git client should initially reach the Load Balancer on port 22, and then be redirected to port 7999. The observed issue, where the connection is prematurely closed on port 22, indicates that the rejection is occurring at the Load Balancer level rather than being an issue directly related to the Bitbucket server.

Solution

The issue should be resolved after modifying the configuration setting at the Load Balancer end for the port redirection.


Last modified on May 23, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.