Description
When attempting to connect to any server the Minecraft client will time out. The server will have no record of the attempted connection. The client has the following error in its log:
java.net.SocketException: Address family not supported by protocol family: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at codechicken.core.CCUpdateChecker$ThreadUpdateCheck.run(CCUpdateChecker.java:47)
Cause
Java is attempting to make a connection to an IPv4 address using the IPv6 protocol.
Solution
Tell Java to use the IPv4 protocol instead using the -Djava.net.preferIPv4Stack=true
option. You can do this by editing the Java launch options in your Minecraft or Modpack Launcher. You may also set Java to always use the option:
- Set
-Djava.net.preferIPv4Stack=true
in the Twitch Launcher - Set
-Djava.net.preferIPv4Stack=true
in the Minecraft Launcher - Set
-Djava.net.preferIPv4Stack=true
in the ATLauncher - Set
-Djava.net.preferIPv4Stack=true
in the Technic Launcher - Set Java to always use
-Djava.net.preferIPv4Stack=true
Set ‘-Djava.net.preferIPv4Stack=true’ in the Twitch Launcher
- Open the Twitch Launcher
- Click on the down-arrow at the top right (next to your username) and click
Settings
- On the left-hand menu, click
Minecraft
- Scroll down to the bottom to the
Advanced
section - Add
-Djava.net.preferIPv4Stack=true
to the end of theAdditional Java Arguments
- Click
Done
Set ‘-Djava.net.preferIPv4Stack=true’ in the Minecraft Launcher
- Open the Minecraft Launcher
- Click on
Launch Options
. (If you can’t see it, click the 3 bars at top right) - Click on the Profile that you want to change
- Enable the
JVM arguments
switch, the box to the right can now be edited - Add
-Djava.net.preferIPv4Stack=true
to the end of theJVM arguments
- Click ‘SAVE’
Set ‘-Djava.net.preferIPv4Stack=true’ in the ATLauncher
- Open the ATLauncher
- Click on the
Settings
button on the right - Click on the
Java/Minecraft
tab at the top - Add
-Djava.net.preferIPv4Stack=true
to the end of theJVM Parameters
- Click the ‘Save’ button at the bottom
Set ‘-Djava.net.preferIPv4Stack=true’ in the Technic Launcher
- Open the Technic Launcher
- Click on the
Launcher Options
button at the top-right - Click on the
Java Settings
tab at the top - Add
-Djava.net.preferIPv4Stack=true
to the end of theJava Args
- Close the
Launcher Options
window using the X at the top-right
Set Java to always use ‘-Djava.net.preferIPv4Stack=true’
WARNING: This will set the option for every Java application that runs on your computer.
Windows
- Click on the
Start
Menu (Windows Icon) - Type in
system
and click on theSystem
option that appears - On the left hand menu, click
Advanced system settings
- Click the
Environment Variables...
button - In the
System variables
list look for_JAVA_OPTIONS
- If it exists:
- Click on it to highlight it and then click on
Edit
- Add
-Djava.net.preferIPv4Stack=true
to the end of the contents of theVariable value
- Click
OK
- If it doesn’t exist:
- Click ‘New’
- Enter
_JAVA_OPTIONS
intoVariable name
- Enter
-Djava.net.preferIPv4Stack=true
intoVariable value
- Click
OK
OSX/Linux
- Open a terminal window
- Check if the environment variable has already been set using the command:
echo $JAVA_OPTS
- If it is set the value will be displayed. Make a note of the value
- Edit the startup script using the command:
- Linux:
vi ~/.bash_proflle
- OSX:
vi /etc/launchd.conf
- Press
i
to enter insert mode - Add the following text on a new line at the end of the file:
- Linux:
JAVA_OPTS="-Djava.net.preferIPv4Stack=true"
- OSX:
setenv JAVA_OPTS "-Djava.net.preferIPv4Stack=true"
- If the variable was alrady previously set:
- Linux:
JAVA_OPTS="<OLD_VALUE> -Djava.net.preferIPv4Stack=true"
- OSX:
setenv JAVA_OPTS "<OLD_VALUE> -Djava.net.preferIPv4Stack=true"
- Press
Esc
to exit insert mode - Type
:wq!
and hitEnter
to save your changes - The setting will take effect when you next start your machine