Bitbucket search server does not start due to "Error resetting config directory"

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 bundled OpenSearch in Bitbucket Server fails to start due to "Error resetting config directory" message.

Environment

  • Bitbucket 7.21+

  • Bundled OpenSearch

Diagnosis

We see the below log snippet in the atlassian-bitbucket.log file:

1 2 3 4 5 6 7 8 9 10 11 Starting Atlassian Bitbucket as the current user INFO [main] c.a.b.s.helper.ConfigDirectoryHelper Backing up existing configuration files INFO [main] c.a.b.s.helper.ConfigDirectoryHelper Existing bundled search configuration needs to be updated INFO [main] c.a.b.s.helper.ConfigDirectoryHelper Copying search configuration to /var/lib/bitbucket/shared/search/config Exception in thread "main" com.atlassian.bitbucket.searchconfig.exception.SearchConfigException: Error resetting config directory /var/lib/bitbucket/shared/search/config at com.atlassian.bitbucket.searchconfig.helper.ConfigDirectoryHelper.resetConfigDir(ConfigDirectoryHelper.java:92) at com.atlassian.bitbucket.searchconfig.helper.ConfigDirectoryHelper.setupConfigDirectory(ConfigDirectoryHelper.java:53) at com.atlassian.bitbucket.searchconfig.configure.DefaultSearchConfigService.configureSearch(DefaultSearchConfigService.java:39) at com.atlassian.bitbucket.searchconfig.SearchConfigCli.main(SearchConfigCli.java:16) Caused by: java.nio.file.AccessDeniedException: /opt/bitbucket/opensearch/config/opensearch-reports-scheduler/reports-scheduler.yml at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)

Cause

When the Bitbucket service tries to start the OpenSearch service and copy over the search configuration files to the /var/lib/bitbucket/shared/search/config folder, it fails due to permission issues on the OpenSearch folder. Here /var/lib/bitbucket is the Bitbucket home directory and could be different for your Bitbucket instance.

Solution

Check the ownership for the OpenSearch folder under the Bitbucket installation directory, which could be /opt/bitbucket/ for example. Ensure that the user and group on the OpenSearch folder are assigned to the user running the Bitbucket service.

  • Check the ownership using the following steps:

    1 2 cd /opt/bitbucket/opensearch ls -lrta
  • Update the permissions for all the files and folders recursively:

    1 chown -R atlbitbucket:atlbitbucket /opt/bitbucket/opensearch

    here atlbitbucket is the user starting Bitbucket, it can be different for you, please replace it with your dedicated Bitbucket user.

  • Restart the Bitbucket service after the permission change and the OpenSearch service should start without issues.

Updated on February 26, 2025

Still need help?

The Atlassian Community is here for you.