Cannot accept connection from remote address /127.0.103.1

I am getting following error when trying to run my junit tests on some linux server:

Cannot accept connection from remote address /127.0.103.1.
Unexpected exception thrown.
org.gradle.messaging.remote.internal.MessageIOException: Could not read message from '/127.0.0.1:47300'.
        at org.gradle.messaging.remote.internal.inet.SocketConnection.receive(SocketConnection.java:88)
        at org.gradle.messaging.remote.internal.hub.MessageHub$ConnectionReceive.run(MessageHub.java:230)
        at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)
Caused by: com.esotericsoftware.kryo.KryoException: Buffer underflow.
        at com.esotericsoftware.kryo.io.Input.require(Input.java:162)
        at com.esotericsoftware.kryo.io.Input.readByte(Input.java:255)
        at org.gradle.messaging.remote.internal.hub.InterHubMessageSerializer$MessageReader.read(InterHubMessageSerializer.java:64)
        at org.gradle.messaging.remote.internal.hub.InterHubMessageSerializer$MessageReader.read(InterHubMessageSerializer.java:53)
        at org.gradle.messaging.remote.internal.inet.SocketConnection.receive(SocketConnection.java:83)
        ... 5 more

I’m ussing gradle wrapper:

[xxx@xxxGradlePlayground]$ ./gradlew -v
Picked up _JAVA_OPTIONS: -Xmx384M
  ------------------------------------------------------------
Gradle 1.9
------------------------------------------------------------
  Build time:
 2013-11-19 08:20:02 UTC
Build number: none
Revision:
   7970ec3503b4f5767ee1c1c69f8b4186c4763e3d
  Groovy:
     1.8.6
Ant:
        Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:
        2.2.0
JVM:
        1.7.0_51 (Oracle Corporation 24.51-b03)
OS:
         Linux 3.10.19-2 amd64

Compilations/jarring works without problem. Also everything works fine on my own laptop.

Some problem with firewall? These tests do nothing with network though…

Gradle needs to be able to accept connections from other Gradle processes on the same machine. For some reason, this isn’t working out here.

I tried few things and looks like on this machine you can’t bind socket to default loopback address like localhost/127.0.x.x, but need to use other network interface e.g. hostname/10.1.0.3. Does gradle always use loopback or is it possible to override this?

From what I can see in the code (‘org.gradle.messaging.remote.internal.inet.InetAddressFactory’), it’s trying to identify loopback addresses on loopback interfaces, which doesn’t appear to be easy in Java 5. This doesn’t seem to be configurable. ‘–debug’ might provide some relevant information.