Java Application Error in Pivotal Cloud Foundry "java.net.SocketException: Protocol family unavailable" when trying to Bind an IPv6 Address to a Socket"
search cancel

Java Application Error in Pivotal Cloud Foundry "java.net.SocketException: Protocol family unavailable" when trying to Bind an IPv6 Address to a Socket"

book

Article ID: 297803

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

Symptoms:

When trying to bind an IPv6 address to a socket, the Java application encounters the following exception and fails to bind:

Java.net.SocketException: Protocol family unavailable

Environment


Cause

The recently published Stemcell 3363.20 disables IPv6 at the kernel level. If you use this Stemcell, you can run into this issue.

Resolution

To prevent your JVM from doing this, set the following two system properties to true:

-Djava.net.preferIPv4Stack=true
-Djava.net.preferIPv4Addresses=true
 

This can likely be done by:
 

cf set-env <APP> JAVA_OPTS '-Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true' 



or the manifest.yml equivalent.