ElasticSearch fails to start (java.lang.RuntimeException: starting java failed) in Bitbucket Server
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
Elasticsearch service fails to start with the 'Error opening log file 'logs/gc.log': Permission denied' error.
Environment
Bitbucket Server 7.6.0 with Bundled ES. It can happen in any version of Bitbucket.
Diagnosis
Exception in thread "main" java.lang.RuntimeException: starting java failed with [1]
Nov 13 17:19:25 sso-services-ppr start-bitbucket.sh[16873]: output:
Nov 13 17:19:25 sso-services-ppr start-bitbucket.sh[16873]: [0.002s][error][logging] Error opening log file 'logs/gc.log': Permission denied
Nov 13 17:19:25 sso-services-ppr start-bitbucket.sh[16873]: [0.002s][error][logging] Initialization of output 'file=logs/gc.log' using options 'filecount=5,filesize=20M' failed.
Cause
The Bitbucket installation folder - /$BITBUCKET_INSTALL/elasticsearch/logs -
doesn't have the write permissions for the Bitbucket user.
Solution
- Confirm Bitbucket user owns the directory by running
chown -R atlbitbucket:atlbitbucket *
- Change the permission of the folder above to have write permissions for the Bitbucket user by running
chmod 755