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
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.
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.