Bitbucket Server is not available due to "java.lang.OutOfMemoryError: unable to create new native thread"
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
Problem
A short time after starting Bitbucket Server, the application stops without any shutdown request.
The following appears in the catalina.out
log:
ℹ️ As of Bitbucket Server 5.x, catalina.out
will no longer exist. It will be written to atlassian-bitbucket.log
instead.
1
java.lang.OutOfMemoryError: unable to create new native thread
Diagnosis
Environment
Linux using systemd as the default init system
For example, Ubuntu 15.10+ first introduced systemd as the default
Diagnostic Steps
No other processes can be started on the server. For example running a
ps
command returns the following:
1
2
atlbitbucket@bitbucket:~$ ps -efH | grep java
-bash: fork: retry: No child processes
Cause
The UserTasksMax
setting in systemd does not allow the creation of a sufficient number of threads.
This setting has a default of 512.
Solution
Resolution
Increase the value of the
DefaultTasksMax
setting by changing the relative line in the /etc/systemd/system.conf to provide a higher number (for example 12288):1
DefaultTasksMax=12288
Restart Bitbucket Server for the change to take effect
Was this helpful?