title: Gradle Daemon for Android Studio Project can't start
body: <p>Okay, new to Android. Fresh install, Windows 10, basic template project with an empty activity. When I start the project it starts gradle sync and starts generating logs in my gradle home with the following error </p>
  
  <pre><code>org.gradle.api.UncheckedIOException: java.io.IOException: Unable to establish loopback connection
      at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:43)
      at org.gradle.internal.remote.internal.inet.SocketConnection.&lt;init&gt;(SocketConnection.java:60)
      at org.gradle.internal.remote.internal.inet.SocketConnectCompletion.create(SocketConnectCompletion.java:39)
      at org.gradle.launcher.daemon.server.DaemonTcpServerConnector$1.execute(DaemonTcpServerConnector.java:73)
      at org.gradle.launcher.daemon.server.DaemonTcpServerConnector$1.execute(DaemonTcpServerConnector.java:69)
      at org.gradle.internal.remote.internal.inet.TcpIncomingConnector$Receiver.run(TcpIncomingConnector.java:112)
      at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
      at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.io.IOException: Unable to establish loopback connection
      at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:101)
      at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:68)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.nio.ch.PipeImpl.&lt;init&gt;(PipeImpl.java:170)
      at sun.nio.ch.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:50)
      at java.nio.channels.Pipe.open(Pipe.java:155)
      at sun.nio.ch.WindowsSelectorImpl.&lt;init&gt;(WindowsSelectorImpl.java:127)
      at sun.nio.ch.WindowsSelectorProvider.openSelector(WindowsSelectorProvider.java:44)
      at java.nio.channels.Selector.open(Selector.java:227)
      at org.gradle.internal.remote.internal.inet.SocketConnection$SocketInputStream.&lt;init&gt;(SocketConnection.java:142)
      at org.gradle.internal.remote.internal.inet.SocketConnection.&lt;init&gt;(SocketConnection.java:58)
      ... 9 more
  Caused by: java.net.SocketException: Permission denied: connect
      at sun.nio.ch.Net.connect0(Native Method)
      at sun.nio.ch.Net.connect(Net.java:454)
      at sun.nio.ch.Net.connect(Net.java:446)
      at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:648)
      at java.nio.channels.SocketChannel.open(SocketChannel.java:189)
      at sun.nio.ch.PipeImpl$Initializer$LoopbackConnector.run(PipeImpl.java:130)
      at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:83)
      ... 19 more
  </code></pre>
  
  <p>I get the same error when I run the basic gradle command against the gradlew.bat file, but when I run <code>set _JAVA_OPTIONS=-Djava.net.preferIPv4Stack=true</code> first then it starts the daemon successfully. Question is, how do I use that information to make the gradle sync on the project work. I've tried adding -Djava.net.preferIPv4Stack=true to the gradle.properties file, tried adding <code>set _JAVA_OPTIONS=-Djava.net.preferIPv4Stack=true</code> to the projects gradle batch file, and now I'm out of options.</p>