user3621841 user3621841 - 4 months ago 74
Java Question

How to force Jetty to use IPv4

I am using standalone jetty 9.1.5 to deploy a java webapp.
I want jetty to use IPv4 instead of IPv6 but I cannot manage to do it!
When I type

netstat -tnlp
I can see the following result:

tcp6 0 0 :::* LISTEN 27535/java

... So that tells me jetty is using IPv6 even when on my
file I have:

<Set name="host"><Property name="" default="" /></Set>

I am also starting jetty with the following java options:

... but to no avail; Jetty keeps using IPv6 and I have not been able to force it to use IPv4.
Any ideas?


Java is making the decision to use IPv4 or IPv6, not Jetty.

Jetty 9.1.5 is very old, consider upgrading to at least the Jetty 9.2.x series.

The example is not an IPv6 Local Address, something is off with your netstat output.

Specify the in your ${jetty.base}/start.ini, do not edit the jetty-http.xml.

Important Note: Do not edit, change, delete, rename, move, etc any content in your ${jetty.home}. Specify your configuration in your ${jetty.base}.

Did you try to connect to your running server using (it will probably work)

If you don't want Java to default to IPv6, then the java command line option would look like this ...

$ cd /path/to/mybase
$ java -jar /path/to/jetty-dist/start.jar

However, if you don't have an IPv4 stack on your machine (such as not having a network interface with an IPv4 address, which is a surprisingly common setup), then this java command line option/argument is pretty much meaningless.