title: Akka AssociationError - LAN address vs localhost
body: <p>I am new to akka and am trying to get a sample to work between multiple JVMs. I am working from the <a href="http://nurkiewicz.blogspot.com/2012/11/remote-actors-discovering-akka.html" rel="nofollow">example shown here</a> but am encountering a problem. At the end of the log below, you can see that there in an AssociationError, saying connection to <code>127.0.0.1:2552</code> was refused.</p>
  
  <p>Earlier in the log (<code>15:35:24.543</code>), I see that remoting was started, and is listening on my LAN address (which I have shown as <code>WWW.XXX.YYY.ZZZ</code>), rather than on localhost.</p>
  
  <pre><code>15:35:24.307 [RandomOrgSystem-akka.actor.default-dispatcher-2] INFO  akka.event.slf4j.Slf4jLogger - Slf4jLogger started
  15:35:24.319 [RandomOrgSystem-akka.actor.default-dispatcher-2] DEBUG akka.event.EventStream - logger log1-Slf4jLogger started
  15:35:24.320 [RandomOrgSystem-akka.actor.default-dispatcher-2] DEBUG a.a.LocalActorRefProvider$SystemGuardian - now supervising Actor[akka://RandomOrgSystem/system/UnhandledMessageForwarder#883086044]
  15:35:24.320 [RandomOrgSystem-akka.actor.default-dispatcher-2] DEBUG akka.event.EventStream - Default Loggers started
  15:35:24.320 [RandomOrgSystem-akka.actor.default-dispatcher-2] DEBUG a.e.LoggingBus$$anonfun$startDefaultLoggers$2$$anon$1 - started (akka.event.LoggingBus$$anonfun$startDefaultLoggers$2$$anon$1@45de530a)
  15:35:24.325 [RandomOrgSystem-akka.actor.default-dispatcher-4] DEBUG a.a.LocalActorRefProvider$SystemGuardian - now supervising Actor[akka://RandomOrgSystem/system/remoting-terminator#-1650950485]
  15:35:24.339 [RandomOrgSystem-akka.actor.default-dispatcher-3] DEBUG a.r.RemoteActorRefProvider$RemotingTerminator - started (akka.remote.RemoteActorRefProvider$RemotingTerminator@4f27077b)
  15:35:24.355 [RandomOrgSystem-akka.actor.default-dispatcher-2] DEBUG a.a.LocalActorRefProvider$SystemGuardian - now supervising Actor[akka://RandomOrgSystem/system/transports#300935452]
  15:35:24.356 [RandomOrgSystem-akka.actor.default-dispatcher-3] DEBUG a.r.Remoting$TransportSupervisor - started (akka.remote.Remoting$TransportSupervisor@2cf5006)
  15:35:24.359 [RandomOrgSystem-akka.actor.default-dispatcher-3] INFO  Remoting - Starting remoting
  15:35:24.364 [RandomOrgSystem-akka.actor.default-dispatcher-2] DEBUG a.a.LocalActorRefProvider$SystemGuardian - now supervising Actor[akka://RandomOrgSystem/system/endpointManager#-594071077]
  15:35:24.364 [RandomOrgSystem-akka.actor.default-dispatcher-2] DEBUG a.r.RemoteActorRefProvider$RemotingTerminator - now monitoring Actor[akka://RandomOrgSystem/system]
  15:35:24.373 [RandomOrgSystem-akka.actor.default-dispatcher-2] DEBUG akka.remote.EndpointManager - started (akka.remote.EndpointManager@7ad99f4a)
  15:35:24.534 [RandomOrgSystem-akka.actor.default-dispatcher-3] DEBUG a.r.Remoting$TransportSupervisor - now supervising Actor[akka://RandomOrgSystem/system/transports/akkaprotocolmanager.tcp0#-2000194523]
  15:35:24.537 [RandomOrgSystem-akka.actor.default-dispatcher-3] DEBUG a.r.transport.AkkaProtocolManager - started (akka.remote.transport.AkkaProtocolManager@749cd006)
  15:35:24.543 [RandomOrgSystem-akka.actor.default-dispatcher-5] INFO  Remoting - Remoting started; listening on addresses :[akka.tcp://RandomOrgSystem@WWW.XXX.YYY.ZZZ:2552]
  15:35:24.545 [RandomOrgSystem-akka.actor.default-dispatcher-2] INFO  Remoting - Remoting now listens on addresses: [akka.tcp://RandomOrgSystem@WWW.XXX.YYY.ZZZ:2552]
  15:35:24.548 [RandomOrgSystem-akka.actor.default-dispatcher-2] DEBUG a.a.LocalActorRefProvider$SystemGuardian - now supervising Actor[akka://RandomOrgSystem/system/remote-watcher#-245042739]
  15:35:24.549 [RandomOrgSystem-akka.actor.default-dispatcher-2] DEBUG a.a.LocalActorRefProvider$SystemGuardian - now supervising Actor[akka://RandomOrgSystem/system/remote-deployment-watcher#1846115901]
  15:35:24.550 [RandomOrgSystem-akka.actor.default-dispatcher-3] DEBUG akka.remote.RemoteDeploymentWatcher - started (akka.remote.RemoteDeploymentWatcher@730a4a32)
  15:35:24.550 [RandomOrgSystem-akka.actor.default-dispatcher-4] DEBUG a.a.LocalActorRefProvider$SystemGuardian - now supervising Actor[akka://RandomOrgSystem/system/deadLetterListener#1544852868]
  15:35:24.552 [RandomOrgSystem-akka.actor.default-dispatcher-4] DEBUG akka.event.DeadLetterListener - started (akka.event.DeadLetterListener@79a422d9)
  15:35:24.555 [RandomOrgSystem-akka.actor.default-dispatcher-5] DEBUG akka.remote.RemoteWatcher - started (akka.remote.RemoteWatcher@4aa0560e)
  15:35:24.555 [RandomOrgSystem-akka.actor.default-dispatcher-5] INFO  akka.actor.ActorSystemImpl - Started
  15:35:24.559 [RandomOrgSystem-akka.actor.default-dispatcher-5] DEBUG a.a.LocalActorRefProvider$Guardian - now supervising Actor[akka://RandomOrgSystem/user/buffer#-400157724]
  15:35:24.570 [RandomOrgSystem-akka.actor.default-dispatcher-5] DEBUG RemoteActorRefProvider - [akka://RandomOrgSystem/] Instantiating Remote Actor [akka.tcp://RandomOrgSystem@127.0.0.1:2552/remote/akka.tcp/RandomOrgSystem@WWW.XXX.YYY.ZZZ:2552/user/buffer/client]
  15:35:24.581 [RandomOrgSystem-akka.actor.default-dispatcher-3] DEBUG akka.remote.RemoteWatcher - Watching: [akka://RandomOrgSystem/system/remote-deployment-watcher -&gt; akka.tcp://RandomOrgSystem@127.0.0.1:2552/remote/akka.tcp/RandomOrgSystem@WWW.XXX.YYY.ZZZ:2552/user/buffer/client]
  15:35:24.582 [RandomOrgSystem-akka.actor.default-dispatcher-3] DEBUG c.b.n.akka.demo.RandomOrgBuffer - started (com.blogspot.nurkiewicz.akka.demo.RandomOrgBuffer@3012db7c)
  15:35:24.584 [RandomOrgSystem-akka.actor.default-dispatcher-3] DEBUG akka.remote.EndpointManager - now supervising Actor[akka://RandomOrgSystem/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FRandomOrgSystem%40127.0.0.1%3A2552-0#-126941538]
  15:35:24.594 [RandomOrgSystem-akka.actor.default-dispatcher-5] DEBUG a.remote.ReliableDeliverySupervisor - started (akka.remote.ReliableDeliverySupervisor@b8235a1)
  15:35:24.594 [RandomOrgSystem-akka.actor.default-dispatcher-5] DEBUG a.remote.ReliableDeliverySupervisor - now monitoring Actor[akka://RandomOrgSystem/system/endpointManager#-594071077]
  15:35:24.594 [RandomOrgSystem-akka.actor.default-dispatcher-5] DEBUG a.remote.ReliableDeliverySupervisor - now supervising Actor[akka://RandomOrgSystem/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FRandomOrgSystem%40127.0.0.1%3A2552-0/endpointWriter#118183353]
  15:35:24.606 [RandomOrgSystem-akka.actor.default-dispatcher-5] DEBUG akka.remote.EndpointWriter - started (akka.remote.EndpointWriter@4b069693)
  15:35:24.606 [RandomOrgSystem-akka.actor.default-dispatcher-5] DEBUG akka.remote.EndpointWriter - now monitoring Actor[akka://RandomOrgSystem/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FRandomOrgSystem%40127.0.0.1%3A2552-0#-126941538]
  15:35:24.616 [RandomOrgSystem-akka.actor.default-dispatcher-3] DEBUG a.r.transport.AkkaProtocolManager - now supervising Actor[akka://RandomOrgSystem/system/transports/akkaprotocolmanager.tcp0/akkaProtocol-tcp%3A%2F%2FRandomOrgSystem%40127.0.0.1%3A2552-1#-1464884820]
  15:35:24.631 [RandomOrgSystem-akka.actor.default-dispatcher-4] DEBUG a.r.transport.ProtocolStateActor - started (akka.remote.transport.ProtocolStateActor@620b5b80)
  15:35:24.656 [RandomOrgSystem-akka.actor.default-dispatcher-5] ERROR akka.remote.EndpointWriter - AssociationError [akka.tcp://RandomOrgSystem@WWW.XXX.YYY.ZZZ:2552] -&gt; [akka.tcp://RandomOrgSystem@127.0.0.1:2552]: Error [Association failed with [akka.tcp://RandomOrgSystem@127.0.0.1:2552]] [
  akka.remote.EndpointAssociationException: Association failed with [akka.tcp://RandomOrgSystem@127.0.0.1:2552]
  Caused by: akka.remote.transport.netty.NettyTransport$$anonfun$associate$1$$anon$2: Connection refused: /127.0.0.1:2552
  ]
  </code></pre>
  
  <p>I'd like it if the remoting started on the localhost address so that I don't have to reconfigure when I change IP address. My <code>application.conf</code> contains:</p>
  
  <pre><code>akka {
      log-config-on-start = off
      loggers = ["akka.event.slf4j.Slf4jLogger"]
      loglevel = "DEBUG"
      actor {
          provider = "akka.remote.RemoteActorRefProvider"
          debug {
              receive = on
              autoreceive = on
              lifecycle = on
              unhandled = on
          }
          deployment {
              /buffer/client {
                  remote = "akka.tcp://RandomOrgSystem@127.0.0.1:2552"
              }
          }
      }
      remote {
          transport = "akka.remote.netty.NettyRemoteTransport"
          log-sent-messages = on
          netty {
              hostname = "127.0.0.1"
          }
      }
  }
  </code></pre>
  
  <p>Thanks,
  Tom</p>