Ali Dogan
Ali Dogan

Reputation: 71

Spring boot application listens over IPv6 without -Djava.net.preferIPv4Stack=true and -Djava.net.preferIPv4Addresses parameters


My question about Spring boot jar. When running jar on production machine as:

java -jar xyz.jar

It does not respond to my request. Because it is listening on ipv6.

But when I run application as
java -jar xyz.jar -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses

It responds my requests.

Is it the production machine's configuration which cause the application to listen over ipv6, or is there any other reasons?

Fortunately
-Djava.net.preferIPv4Stack=true
-Djava.net.preferIPv4Addresses
parameters solved my problem. But I am confused!!

Note: Tomcat is used as embedded server.
Spring boot version 1.5.4 RELEASE

Upvotes: 7

Views: 8778

Answers (1)

Pierluigi Vernetto
Pierluigi Vernetto

Reputation: 2050

Here https://docs.oracle.com/javase/8/docs/technotes/guides/net/ipv6_guide/index.html I read that "The Java networking stack first checks whether IPv6 is supported on the underlying OS. If IPv6 is supported, it tries to use the IPv6 stack."

To check if your Linux machine supports IPv6, simply run "cat /proc/net/if_inet6" and if you see some output it means it's enabled.

Upvotes: 3

Related Questions