Rich Dougherty

Minecraft server and IPv6

I was having trouble starting a Minecraft server in Ubuntu Natty. I could connect locally, but my friend couldn't connect over the internet.

I used the standard command to start the server.

$ java -Xmx1024M -Xms1024M \
-jar minecraft_server.jar nogui

I noticed that the server was listening on an IPv6 address. My local network and internet connection is IPv4-only, so my friend would obviously be unable to connect.

$ netstat -an | grep 25565
tcp6  0  0  :::25565  :::*  LISTEN

The solution was to pass a property to Java telling it to bind to an IPv4 address.

$ java -Xmx1024M -Xms1024M -Djava.net.preferIPv4Stack=true \
-jar minecraft_server.jar nogui

With that option the server will listen on an IPv4 address.

$ netstat -an | grep 25565
tcp  0  0  0.0.0.0:25565  0.0.0.0:*  LISTEN