Pivotal Knowledge Base

Follow

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

Environment

 Product  Version
 Pivotal Cloud Foundry  1.10
 Java Application  All Versions

Purpose

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

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.

 

Comments

Powered by Zendesk