Unable to Connect to Any Minecraft Server - java.net.SocketException: Address family not supported by protocol family: connect


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)


Java is attempting to make a connection to an IPv4 address using the IPv6 protocol.


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

  1. Open the Twitch Launcher
  2. Click on the down-arrow at the top right (next to your username) and click Settings
  3. On the left-hand menu, click Minecraft
  4. Scroll down to the bottom to the Advanced section
  5. Add -Djava.net.preferIPv4Stack=true to the end of the Additional Java Arguments
  6. Click Done

Set ‘-Djava.net.preferIPv4Stack=true’ in the Minecraft Launcher

  1. Open the Minecraft Launcher
  2. Click on Launch Options. (If you can’t see it, click the 3 bars at top right)
  3. Click on the Profile that you want to change
  4. Enable the JVM arguments switch, the box to the right can now be edited
  5. Add -Djava.net.preferIPv4Stack=true to the end of the JVM arguments
  6. Click ‘SAVE’

Set ‘-Djava.net.preferIPv4Stack=true’ in the ATLauncher

  1. Open the ATLauncher
  2. Click on the Settings button on the right
  3. Click on the Java/Minecraft tab at the top
  4. Add -Djava.net.preferIPv4Stack=true to the end of the JVM Parameters
  5. Click the ‘Save’ button at the bottom

Set ‘-Djava.net.preferIPv4Stack=true’ in the Technic Launcher

  1. Open the Technic Launcher
  2. Click on the Launcher Options button at the top-right
  3. Click on the Java Settings tab at the top
  4. Add -Djava.net.preferIPv4Stack=true to the end of the Java Args
  5. 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.


  1. Click on the Start Menu (Windows Icon)
  2. Type in system and click on the System option that appears
  3. On the left hand menu, click Advanced system settings
  4. Click the Environment Variables... button
  5. In the System variables list look for _JAVA_OPTIONS
  6. 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 the Variable value
  • Click OK
  1. If it doesn’t exist:
  • Click ‘New’
  • Enter _JAVA_OPTIONS into Variable name
  • Enter -Djava.net.preferIPv4Stack=true into Variable value
  • Click OK


  1. Open a terminal window
  2. Check if the environment variable has already been set using the command:
  • echo $JAVA_OPTS
  1. If it is set the value will be displayed. Make a note of the value
  2. Edit the startup script using the command:
  • Linux: vi ~/.bash_proflle
  • OSX: vi /etc/launchd.conf
  1. Press i to enter insert mode
  2. 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"
  1. 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"
  1. Press Esc to exit insert mode
  2. Type :wq! and hit Enter to save your changes
  3. The setting will take effect when you next start your machine
  • 4 Users Found This Useful

Was this answer helpful?

 Print this Article

Also Read

Diagnosing lag issues with a Timings report

If you are running a server with many plugins it can be very difficult to diagnose performance...

Help! My Minecraft World Disappeared

If your Minecraft world is gone or the world has changed without you knowing why, this...

Flying is not enabled on this server

If you or your players have been kicked from your server with this error message:...

Fixing Ticking Tile Entity Error

One of the most common issues on a modded Minecraft server, a ticking tile entity causes...

Crashing on connecting due to holding a bugged item

This article relates to a client crash that is caused by holding a bugged item in the player's...