Bitbucket Server is not available due to "java.lang.OutOfMemoryError: unable to create new native thread"
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
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.
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:
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.
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):DefaultTasksMax=12288
- Restart Bitbucket Server for the change to take effect