title: Akka cluster - Association with remote system has failed...Reason: [Association failed]
body: <p>I have a simple POC with two actors:</p>
  
  <pre><code>public final class Task1Actor extends AbstractLoggingActor {
    public Task1Actor() {
      final UnitPFBuilder&lt;Object&gt; builder = ReceiveBuilder.create()
          .matchAny(message -&gt; {
            log().warning("Received unknown message: {}", message);
            unhandled(message);
          });
      receive(builder.build());
    }
  
    @Override
    public void preStart() throws Exception {
      IntStream.range(0, 5).forEach(i -&gt; {
        final ActorRef actor = context().actorOf(Props.create(Task2Actor.class));
        actor.tell(RandomStringUtils.randomAlphabetic(10), self());
      });
    }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public final class Task2Actor extends AbstractLoggingActor {
    public Task2Actor() {
      final UnitPFBuilder&lt;Object&gt; builder = ReceiveBuilder.create()
          .match(String.class, this::process)
          .matchAny(message -&gt; {
            log().warning("Received unknown message: {}", message);
            unhandled(message);
          });
      receive(builder.build());
    }
  
    private void process(final String message) {
      log().debug("Processing message: {}", message);
      // Do something useful here in the (not-so far) future
    }
  }
  </code></pre>
  
  <p>This is the main class:</p>
  
  <pre><code>final class ClusterSample {
    public static void main(final String... args) throws Exception {
      ClusterSample.start(2251);
      ClusterSample.start(2252);
      ClusterSample.start(0);
    }
  
    private static void start(final int port) {
      final Config config = ConfigFactory.parseString(String.format("akka.remote.netty.tcp.port = %s", port))
          //.withFallback(ConfigFactory.parseString(String.format("akka.cluster.roles = [%s]", role)))
          .withFallback(ConfigFactory.load("cluster"));
      ActorSystem system = ActorSystem.create("ClusterSystem", config);
      system.actorOf(Props.create(Task1Actor.class));
    }
  }
  </code></pre>
  
  <p>...and these are my configuration files (<code>application.conf</code> and <code>cluster.conf</code> respectively):</p>
  
  <pre><code>akka {
    actor {
      default-dispatcher { throughput = 5 }
      provider = cluster
    }
  
    cluster {
      seed-nodes = [ "akka.tcp://ClusterSystem@127.0.0.1:2551", "akka.tcp://ClusterSystem@127.0.0.1:2552" ]
      # roles = ["role"]
    }
  
    remote {
      log-remote-lifecycle-events = off
      netty.tcp {
        hostname = 127.0.0.1
        port = 0
      }
    }
  
    loggers = [ "akka.event.slf4j.Slf4jLogger" ]
  
    logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
  
    loglevel = DEBUG
  }
  </code></pre>
  
  <hr>
  
  <pre><code>include "application"
  
  akka.cluster.min-nr-of-members = 2
  
  akka.cluster.role {
    watson.min-nr-of-members = 2
  }
  
  akka.actor.deployment {
  }
  </code></pre>
  
  <p>What I'm trying to achieve here is to "form a cluster" from an already established flow. So I used to have those actors (can be any flow really) and now I'm trying to make them work in (or as) a cluster. I just started reading about it so I'm not very familiar with this.</p>
  
  <p>The errors I'm getting are:</p>
  
  <pre><code>03-09-2017 16:52:43.749 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-20] - Processing message: GCGboeqRKJ
  03-09-2017 16:52:43.749 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-21] - Processing message: ykhePhziFT
  03-09-2017 16:52:43.749 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-2] - Processing message: SFvnRAlGgg
  03-09-2017 16:52:43.753 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-21] - Processing message: bMgBtCzWCI
  03-09-2017 16:52:43.753 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-20] - Processing message: ifoOOmqbbv
  03-09-2017 16:52:43.753 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-2] - Processing message: ZekwWXmmSQ
  03-09-2017 16:52:43.754 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-21] - Processing message: MqXGoSQSzU
  03-09-2017 16:52:43.754 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-20] - Processing message: NrdVYAFgrR
  03-09-2017 16:52:43.754 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-2] - Processing message: GsjyIsxetC
  03-09-2017 16:52:43.754 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-21] - Processing message: LpVNmbriXO
  03-09-2017 16:52:43.754 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-20] - Processing message: HCFzOjJwnO
  03-09-2017 16:52:43.755 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-2] - Processing message: iqflQMSeJF
  03-09-2017 16:52:43.755 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-21] - Processing message: HlyMdMJfUs
  03-09-2017 16:52:43.755 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-20] - Processing message: jlwxzLmRsF
  03-09-2017 16:52:43.755 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-2] - Processing message: XPSmMYekCs
  03-09-2017 16:52:43.794 |-  WARN in ReliableDeliverySupervisor:78 [ClusterSystem-akka.actor.default-dispatcher-20] - Association with remote system [akka.tcp://ClusterSystem@127.0.0.1:2552] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://ClusterSystem@127.0.0.1:2552]] Caused by: [Connection refused: /127.0.0.1:2552]
  03-09-2017 16:52:43.794 |-  WARN in ReliableDeliverySupervisor:78 [ClusterSystem-akka.actor.default-dispatcher-21] - Association with remote system [akka.tcp://ClusterSystem@127.0.0.1:2552] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://ClusterSystem@127.0.0.1:2552]] Caused by: [Connection refused: /127.0.0.1:2552]
  03-09-2017 16:52:43.794 |-  WARN in ReliableDeliverySupervisor:78 [ClusterSystem-akka.actor.default-dispatcher-20] - Association with remote system [akka.tcp://ClusterSystem@127.0.0.1:2551] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://ClusterSystem@127.0.0.1:2551]] Caused by: [Connection refused: /127.0.0.1:2551]
  03-09-2017 16:52:43.794 |-  WARN in ReliableDeliverySupervisor:78 [ClusterSystem-akka.actor.default-dispatcher-2] - Association with remote system [akka.tcp://ClusterSystem@127.0.0.1:2551] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://ClusterSystem@127.0.0.1:2551]] Caused by: [Connection refused: /127.0.0.1:2551]
  03-09-2017 16:52:43.795 |-  WARN in ReliableDeliverySupervisor:78 [ClusterSystem-akka.actor.default-dispatcher-21] - Association with remote system [akka.tcp://ClusterSystem@127.0.0.1:2551] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://ClusterSystem@127.0.0.1:2551]] Caused by: [Connection refused: /127.0.0.1:2551]
  03-09-2017 16:52:43.796 |-  WARN in ReliableDeliverySupervisor:78 [ClusterSystem-akka.actor.default-dispatcher-2] - Association with remote system [akka.tcp://ClusterSystem@127.0.0.1:2552] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://ClusterSystem@127.0.0.1:2552]] Caused by: [Connection refused: /127.0.0.1:2552]
  </code></pre>
  
  <p>I'm executing this on the same machine and nothing is using those ports...guaranteed. I have all the dependencies in my Gradle config, but still, I can't make it to work without issues.</p>