How to force Bitbucket Data Center to use IPv4 instead of IPv6
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
When IPv6 is enabled on the Linux server, Bitbucket utilizes IPv6, causing the processes to bind and listen on the IPv6 socket instead of IPv4.
Environment
5.8+
Diagnosis
When running a Bitbucket Server or Data Center on a Linux node enabled with IPv6, Bitbucket will, by default, bind and listen on the IPv6 socket for HTTP and SSH traffic. To check the internet protocol being used, you can run the command below to find out.
1
2
3
netstat -tulnp | grep 799
tcp6 0 0 :::7990 :::* LISTEN 5050/java
tcp6 0 0 :::7999 :::* LISTEN 5050/java
Cause
The reason you are seeing IPv6 is because of Java and how it behaves in Dual-Stack environments. Bitbucket has no control on these capabilities itself. It's dependent upon the Java network stack behavior. The latest JVMs place higher priority on the IPv6 stack, rather than the IPv4 stack.
The fix for this would be changing the priority of the network stacks through the JVM parameter, on all the Bitbucket nodes and restarting the Bitbucket application itself for the updated JVM arguments to take effect.
Solution
Force the Bitbucket Java process to use IPv4 by adding the parameters below to the JVM_SUPPORT_RECOMMENDED_ARGS
in the <BITBUCKET_INSTALL>/bin/_start-webapp.sh
file.
1
JVM_SUPPORT_RECOMMENDED_ARGS="-Djava.net.preferIPv4Stack=true"
ℹ️ After implementing the above-mentioned changes, ensure to restart the Bitbucket service for the modifications to take effect. After the restart, you should observe the following.
1
2
3
netstat -tulnp | grep 799
tcp 0 0 0.0.0.0:7999 0.0.0.0:* LISTEN 16930/java
tcp 0 0 0.0.0.0:7990 0.0.0.0:* LISTEN 16930/java
Was this helpful?