Bamboo Data Center build git ls-remote failed with "Couldn't connect to server" error

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. 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

Bamboo  executes a git ls-remote command while running a 'Source Code Checkout' task to query remote repositories for references without needing to clone or fetch the entire repository as part of updating source code to the latest revision.

This may sometimes fails due to connectivity issues to the repository server with an error like 'Failed to connect to localhost port 3128 after 1003 ms: Couldn't connect to server'.

Environment

Observed in Bamboo Windows environment  

Diagnosis

You will observe the below error in build logs

Git checkout error message
error 18-Jun-2024 12:34:09 Caused by: com.atlassian.bamboo.plugins.git.GitCommandException: command ['C:\Program Files\Git\cmd\git.exe' -c credential.helper= -c 'credential.helper=store --file=C:/Windows/Temp/GITCRE~1.TMP' ls-remote <REPOSITORY_URL>] failed with code 128. Working directory was [C:\WINDOWS\TEMP]., stderr:
error 18-Jun-2024 12:34:09 fatal: unable to access '<REPOSITORY_URL>': Failed to connect to localhost port 3128 after 1289 ms: Couldn't connect to server
error 18-Jun-2024 12:34::09 at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runCommand(GitCommandProcessor.java:791)
error 18-Jun-2024 12:34:09 at com.atlassian.bamboo.plugins.git.GitCommandProcessor.getRemoteRefs(GitCommandProcessor.java:536)


Cause

3128 is the default port number where the HTTP/TCP proxy is used to listen both HTTP and HTTPS traffic.

And if it the proxy server is not running or a misconfigured HTTP_PROXY environment variable or facing some other issues it may not connect to repository.

Solution

  • Checking Proxy server status and restart
    • Check the proxy server status by running the command "netsh winhttp show proxy" in Windows or "netstat -tuln | grep 3128" in Linux 
  • Check HTTP_PROXY value and update
    • Check HTTP_PROXY in environment variable
    • Check the git http-proxy settings by running the command 'git config --global --get http.proxy' are set correctly.
  • Unset the proxy setting if you are not planning to use proxy.
    • Remove the environment variable by running 'set HTTP_PROXY='  in Windows or 'unset HTTP_PROXY' in Linux
    • For git run the command:  git config --global --unset http.proxy



Last modified on Oct 24, 2024

Was this helpful?

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