# Akka Cluster Connection Refused Between Machines

**URL:** <https://discuss.akka.io/t/akka-cluster-connection-refused-between-machines/7263>\
**Category:** Akka Cluster\
**Tags:** akka, akka-typed, scala, akka-cluster\
**Created:** [September 28, 2020, 7:51pm UTC](https://discuss.akka.io/t/akka-cluster-connection-refused-between-machines/7263 "2020-09-28T19:51:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![khardee1](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/khardee1/32/2037_2.png) [@khardee1](https://discuss.akka.io/u/khardee1)\
**Post date:** [September 28, 2020, 7:51pm UTC](https://discuss.akka.io/t/akka-cluster-connection-refused-between-machines/7263/1 "2020-09-28T19:51:58Z")

</div>

I am crossposting this issue between here and StackOverflow ([https://stackoverflow.com/questions/64108688/akka-cluster-connection-refused-between-machines](https://stackoverflow.com/questions/64108688/akka-cluster-connection-refused-between-machines)) since this is specific to Akka.

I am attempting to make a project using Akka Clustering, and have been using the akka-cluster-sample-scala from Lightbend([https://github.com/akka/akka-samples/tree/2.6/akka-sample-cluster-scala](https://github.com/akka/akka-samples/tree/2.6/akka-sample-cluster-scala)) as a base. As it lacks much direct information on connecting across a network, I modified the application.conf to look more like this:

```auto
akka {
  actor {
    provider = cluster

    serialization-bindings {
      "sample.cluster.CborSerializable" = jackson-cbor
    }
  }
  remote {
    artery {
      canonical.hostname = "127.0.0.1"
      canonical.port = 0
    }
  }
  cluster {
    seed-nodes = [
      "akka://ClusterSystem@131.194.71.132:25251",
      "akka://ClusterSystem@131.194.71.132:25252",
      "akka://ClusterSystem@131.194.71.133:25251",
      "akka://ClusterSystem@131.194.71.133:25252"]
    downing-provider-class = "akka.cluster.sbr.SplitBrainResolverProvider"
  }
}

```

When run across these two machines, Akka fails to be able to connect over TCP between them, leading to the following warnings:

```auto
[info] [2020-09-28 14:34:37,877] [WARN] [akka.stream.Materializer] [] [ClusterSystem-akka.actor.default-dispatcher-5] - [outbound connection to [akka://ClusterSystem@131.194.71.132:25251], control stream] Upstream failed, cause: StreamTcpException: Tcp command [Connect(131.194.71.132:25251,None,List(),Some(5000 milliseconds),true)] failed because of java.net.ConnectException: Connection refused

```

Is there anything notably wrong that may be causing this, or something more specifically needing to be reconfigured in order to allow connection over TCP between these machines?

---

<div class="post-metadata">

**Author:** ![johanandren](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/johanandren/32/85_2.png) [@johanandren](https://discuss.akka.io/u/johanandren)\
**Post date:** [September 29, 2020, 9:21am UTC](https://discuss.akka.io/t/akka-cluster-connection-refused-between-machines/7263/2 "2020-09-29T09:21:39Z")

</div>

`canonical.hostname` cannot be `127.0.0.1` and port `0` but must be configured to be the public ip/hostname and port that other nodes can use to reach the node.

So for `131.194.71.132:25251` it needs to be `131.194.71.132` and `25251` for example.

---

<div class="post-metadata">

**Author:** ![khardee1](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/khardee1/32/2037_2.png) [@khardee1](https://discuss.akka.io/u/khardee1)\
**Post date:** [September 29, 2020, 3:19pm UTC](https://discuss.akka.io/t/akka-cluster-connection-refused-between-machines/7263/3 "2020-09-29T15:19:43Z")

</div>

Thank you so much for taking the time to respond. This just helped immensely.
