Troubleshooting steps for Bitbucket Server Code Search

Still need help?

The Atlassian Community is here for you.

Ask the community


This page contains the troubleshooting steps that can be performed to understand the reasons leading to the Bitbucket Server Code Search functionality not being available.

The steps below apply for the Embedded Elasticsearch. If you have "Bitbucket Data Center" it means that you do not have Embedded Elasticsearch but your own self-managed Elasticsearch instance and therefore some of the troubleshooting steps below might not apply to your environment.

Troubleshooting steps

Check the status of Elasticsearch

You can see the index progress by going to:


Example results looks like the following:

"queues": {
"delay": 0,
"event": 0
"status": "IDLE"

Result Definitions:

  • delay = Minutes in which the index queue is delayed. Either by failures, retries, or other performance reasons
  • event = Number of events triggered for index. There are ~2 events per repository. Existing event queue size for indexing is 50k per node.

This provides a look into the current queue. If for some reason there's an event that fails to queue, or there's an error in indexing, it'll be placed onto a queue that delays by 5 minutes. When it sits at zero for a while, we can be confident that indexing is complete (for now). This is a moving target as new events coming in will be added to the queue, but is a good guide for when indexing is done. Overall, as long as search is working, that delayed queue will eventually complete and the status will change to idle.

Check that Elasticsearch is starting with the atlbitbucket user

Ideally you want Elasticsearch through the services that we deploy when you set your environment up by using the installer.

On Linux, you should run the following commands as root (the service will make sure to change into the atlbitbucket user):

# service atlbitbucket_search status
# service atlbitbucket_search start
# service atlbitbucket_search stop

Bitbucket Server 5.0

 Starting with Bitbucket Server 5.0+, there will no longer be a atlbitbucket_search service. Elasticsearch will be started as a result of starting the atlbitbucket service.

Check the username/password for Elasticsearch

Check if you're hitting this: Test button in Elasticsearch for Bitbucket server results in the access denied

Make sure that you did not update the Elasticsearch username and password in the Bitbucket Server user interface, if this is the case you'll need to reset them by following these steps:

  1. locate the $BITBUCKET_HOME/shared/search/buckler/buckler.yml file
  2. Retrieve the username (auth.basic.username attribute) and the password (auth.basic.password attribute) and update the ones available to Bitbucket Server in the user interface

If you did not update them, then there is no need to change anything.

Configure details of your Elasticsearch instance within Bitbucket Server

To configure the details of your Elasticsearch instance within the Bitbucket Server UI, go to the Administration settings page, then click Server Settings. At the bottom of the page is where you can configure the details of your Elasticsearch instance.


Another way to configure connection settings is via file (resides in $BITBUCKET_HOME/shared).

If a parameter is set in the properties file, it cannot be edited later from the admin UI. Any changes that need to be made to the Elasticsearch configuration must be made within the file (which requires an application restart to take effect).

  1. In the $BITBUCKET_HOME directory, create a new directory called shared.
  2. In the $BITBUCKET_HOME/shared directory, create a text file named
  3. Add these Elasticsearch properties to the file.

    Parameter name for properties file

Check the Elasticsearch is writing to its own logs

In a very specific situation, we saw Elasticsearch completely hang and not write in the logs or bind to its port as defined in BITBUCKET_HOME/shared/search/elasticsearch.yml

The symptoms are:

  • tail -f $BITBUCKET_HOME/log/search/bitbucket_search.log
    • Nothing happens
  • ps -ef | grep elastic
    • reveals Elasticsearch is up and running
  • netstat -tulnp 
    • as atlbitbucket user does not show the port 7992 on listen. You can't see the PID of Elasticsearch listened
  • telnet localhost 7992
    • Connection is refused

If you run as atlbitbucket user:

jstack $ELASTIC_SEARCH_PID > elasticsearch_threads.`date +%s`.txt

You will get the following thread dump as a result:

"main" #1 prio=5 os_prio=0 tid=0x00007f4a6800a800 nid=0x6710 runnable [0x00007f4a6e25a000]
   java.lang.Thread.State: RUNNABLE
	at sun.nio.fs.UnixNativeDispatcher.stat0(Native Method)
	at sun.nio.fs.UnixNativeDispatcher.stat(
	at sun.nio.fs.UnixFileAttributes.get(
	at sun.nio.fs.UnixFileStore.devFor(
	at sun.nio.fs.UnixFileStore.<init>(
	at sun.nio.fs.LinuxFileStore.<init>(
	at sun.nio.fs.LinuxFileSystem.getFileStore(
	at sun.nio.fs.UnixFileSystem$FileStoreIterator.readNext(
	at sun.nio.fs.UnixFileSystem$FileStoreIterator.hasNext(
	- locked <0x00000000c0b3c088> (a sun.nio.fs.UnixFileSystem$FileStoreIterator)
	at org.apache.lucene.util.IOUtils.getFileStore(
	at org.apache.lucene.util.IOUtils.spinsLinux(
	at org.apache.lucene.util.IOUtils.spins(
	at org.elasticsearch.env.ESFileStore.<init>(
	at org.elasticsearch.env.Environment.<clinit>(
	at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment(
	at org.elasticsearch.common.cli.CliTool.<init>(
	at org.elasticsearch.common.cli.CliTool.<init>(
	at org.elasticsearch.bootstrap.BootstrapCLIParser.<init>(
	at org.elasticsearch.bootstrap.Bootstrap.init(
	at org.elasticsearch.bootstrap.Elasticsearch.main(

According to the discussion below:

A NFS mount that is unreacheable, for example, could cause such scenario. As the Elasticsearch dev explains, Elasticsearch checks all mount points on your machine during startup.

If you facing that it also means:

That a df on your system won't return the shell line; it will hang indefinitely.


You really need to check which one is the failing mount point. After that, restarting ES works.

Enable DEBUG level logs

If additional troubleshooting is required and the debug log level of the Bitbucket Server to Elasticsearch is required, the following command will enable it:

curl -u <ADMIN_USERNAME> -v -X PUT -d "" -H "Content-Type: application/json" <BASE_URL>/rest/api/latest/logs/logger/

The additional log lines will be added to the atlassian-bitbucket.log file. Refer to the Enable debug logging page for more information and alternative methods to enable debug logging.

Check the Elasticsearch and Bitbucket Server logs for error messages

You might have some obvious log messages that could help you address the issue.

These are logs you should check:

  • $BITBUCKET_HOME/log/atlassian-bitbucket.log
  • $BITBUCKET_HOME/log/search/bitbucket_search.log
Check the Elasticsearch service scripts are installed

Bitbucket Server 5.0

 Starting with Bitbucket Server 5.0+, there will no longer be a atlbitbucket_search service. Elasticsearch will be started as a result of starting the atlbitbucket service.

Verify if the atlbitbucket_search has been created:

ll /etc/init.d/atlbitbucket_search

If the file exists, but the process is not up and running, perform the following command as root:

# service atlbitbucket_search start

Note that the service to stop/start Elasticsearch is different to the service to stop/start Bitbucket server. More details are explained on Start and stop Bitbucket.

Bitbucket Server

# service atlbitbucket status
# service atlbitbucket stop
# service atlbitbucket start


# service atlbitbucket_search status
# service atlbitbucket_search start
# service atlbitbucket_search stop

Check that the Elasticsearch configuration files are present

 Check that the following files are present under BITBUCKET_HOME/shared/search:

├── buckler
│   └── buckler.yml
├── elasticsearch.yml
└── logging.yml

If these files are missing, do the following:

  1. Stop atlbitbucket_search
  2. Copy the contents of BITBUCKET_INSTALL/elasticsearch/config-template into BITBUCKET_HOME/shared/search
  3. Start the atlbitbucket_search service

    # service atlbitbucket_search status
    # service atlbitbucket_search start
    # service atlbitbucket_search stop

    Bitbucket Server 5.0

     Starting with Bitbucket Server 5.0+, there will no longer be a atlbitbucket_search service. Elasticsearch will be started as a result of starting the atlbitbucket service.

  4. Follow the steps in the "Check the username/password for Elasticsearch" to retrieve the password from the buckler.yml file and add it to the Search settings.

This unexpected behaviour is currently under investigation and tracked in our public facing issue tracker: BSERV-9056 - Getting issue details... STATUS

Check that you can connect to port 7992 locally

The user/password required by Elasticsearch can be obtained by following the steps on the expand box above "Check username/password for Elasticsearch".

The steps below should be run from the server where your Bitbucket Server/Elasticsearch instance are running. The reason why we reinforce it has to be a local connection is due to the configuration that we ship for Elasticsearch on $BITBUCKET_HOME/shared/search/elasticsearch.yml.

You won't be able to browse Elasticsearch from a remote machine based on the Elasticsearch configuration we ship. If you're installing your own remote Elasticsearch, you should configure the on <Elasticsearch_Config_dir>/elasticsearch.yml.

Please refer to Elasticsearch documentation to understand why: Special values for

Click to see the configuration we ship with the bundled Elasticsearch on elasticsearch.yml...
[root@mybbs search]# cat elasticsearch.yml bitbucket_search
  name: bitbucket_bundled
  local: true _localhost_ false

action.auto_create_index: false
index.mapper.dynamic: false
http.port: 7992

Access the Elasticsearch user interface at the Elasticsearch bundled URL. From a browser window running locally on the server where Bitbucket is hosted, hit the following URL: http://localhost:7992

If the following login dialog is displayed, Elasticsearch is up and running:


If you don't have a local browser on the server that is running Bitbucket Server, you should also be able to run the following command successfully:

$ curl -u username:password http://localhost:7992
  "name" : "bitbucket_bundled",
  "cluster_name" : "bitbucket_search",
  "version" : {
    "number" : "2.3.1",
    "build_hash" : "bd980929010aef404e7cb0843e61d0665269fc39",
    "build_timestamp" : "2016-04-04T12:25:05Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.0"
  "tagline" : "You Know, for Search"


$ telnet localhost 7992
Connected to localhost.
Escape character is '^]'.
 $ netstat -an | grep 7992


  • As a result on your browser, you should expect to see something similar to that on your browser:
  "name" : "bitbucket_bundled",
  "cluster_name" : "bitbucket_search",
  "version" : {
    "number" : "2.3.1",
    "build_hash" : "bd980929010aef404e7cb0843e61d0665269fc39",
    "build_timestamp" : "2016-04-04T12:25:05Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.0"
  "tagline" : "You Know, for Search"
Check the Elasticsearch process is up and running
pgrep -fl elasticsearch

or its equivalent

ps -ef | grep elasticsearch

This would reveal if your server is listening on port 7992 on Linux and which PID is doing it:

$ netstat -tulnp

Last modified on May 24, 2021

Was this helpful?

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