SocketException to Announce 'Invalid argument' for an Available Port

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

Symptom

Throw the SocketException to announce "Invalid argument" for an available port.

1 2 3 4 5 6 7 8 9 SEVERE: StandardServer.await: create[8005]: java.net.SocketException: Invalid argument at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365) at java.net.ServerSocket.bind(ServerSocket.java:319) at java.net.ServerSocket.<init>(ServerSocket.java:185) at org.apache.catalina.core.StandardServer.await(StandardServer.java:363) ...

Root Cause

That socket may be created for IPv6 only.

Resolution

  1. Use "sysctl net.ipv6.bindv6only" to check if "net.ipv6.bindv6only = 1" in the local environment, if so turn it off:

    1 2 sysctl -w net.ipv6.bindv6only = 0
  2. If this doesn't work, try to set it by JVM parameters. Add "-Djava.net.preferIPv4Stack=true" into JAVA_OPTS. See Setting Properties and Options on Startup for more information on how to set a system property.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.