Repository management shows error "Could not get repositories" in Bitbucket Data Center
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs 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
The repository management in Bitbucket Data Center shows the error "Could not get repositories" as shown in the screenshot below.
Environment
7.14.0+
Diagnosis
You will be seeing a connection refused error for GET /rest/search/latest/repository-management call in the atlassian-bitbucket.log.
DEBUG [http-nio-27140-exec-8] admin @1D0HM58x1214x55x0 1q32l3d 127.0.0.1 "GET /rest/search/latest/repository-management HTTP/1.1" c.a.b.i.s.search.rest.SearchResource Connection exception: Connection refused
Cause
The repository management functionality makes use of the Search component (The process that is responsible for the code search in Bitbucket). So any issue with bitbucket-elasticsearch connectivity could affect displaying the repository list in the repository management screen.
There could be multiple reasons why Bitbucket is not able to connect to Elasticsearch
- Bitbucket could have started as root user.
- The elastic search process could have been killed by some external entity like an OOM killer.
Solution
- Run Bitbucket Server with a dedicated user
Run the below command to check if Search is actually running on your server
ps -ef | grep -i search
If it's not running, please manually stop and start Bitbucket using the ./start-bitbucket.sh script inside the bin folder of the installation directory.
If the search is still not starting or not connecting with Bitbucket, please create a support request with the output of .start-bitbucket.sh script execution.