Daniel
Daniel

Reputation: 103

consul - connect client to server

I'm new at consul and I try to setup a server-client environment. I have started my server with the following command and configuration:

consul.exe agent -ui -config-dir=P:\Consule\config

The config file looks the following ("P:\Consule\config\server.json")

{
    "bootstrap": false,
    "server": true,
    "datacenter": "MyServices",
    "data_dir": "P:\\Consule\\data",
    "log_level": "INFO"
}

Output when I start consul from commandline with above command:

==> Starting Consul agent...
==> Consul agent running!
       Version: 'v0.8.3'
       Node ID: '1a244456-e725-44be-0549-33603ea7087d'
       Node name: 'MYCOMPUTERNAMEA'
       Datacenter: 'myservices'
       Server: true (bootstrap: false)
       Client Addr: 127.0.0.1 (HTTP: 8500, HTTPS: -1, DNS: 8600)
       Cluster Addr: 127.0.0.1 (LAN: 8301, WAN: 8302)
       Gossip encrypt: false, RPC-TLS: false, TLS-Incoming: false
       Atlas: <disabled>

Now, at another computer in my domain I try to run an consul client with follwoing commandline and config-file:

consul.exe agent -config-dir C:\Consul -bind=127.0.0.1

Config file ("C:\Consul\client.json")

{
    "server": false,
    "datacenter": "MyServices",
    "data_dir": "C:\\TEMP",
    "log_level": "INFO",
    "start_join": ["MYCOMPUTERNAMEA"]
}

But I always get follwing output/error message:

==> Starting Consul agent...
==> Joining cluster...
==> 1 error(s) occurred:

* Failed to join <IP_OF_MYCOMPUTERNAMEA>: dial tcp <IP_OF_MYCOMPUTERNAMEA>:8301: connectex: No connection could be made because the target machine actively refused it.

Does anyone know what I'm doing wrong?

Thanks and best regards

Upvotes: 2

Views: 2988

Answers (1)

Stanislav
Stanislav

Reputation: 28106

I suppose, the reason is that your server is available only for 127.0.0.1 ip-address, which is localhost ip and available only from the same server. This can be seen here:

Client Addr: 127.0.0.1 (HTTP: 8500, HTTPS: -1, DNS: 8600)
Cluster Addr: 127.0.0.1 (LAN: 8301, WAN: 8302)

You have to configure your server, to make it listening all network interfaces or some specific interface, which have to be available from other server.

Try to run it with the client and advertise options set to 0.0.0.0 (or some specific ip). Read about it here and here.

And you might have to delete -bind=127.0.0.1 from the client configuration, since it might be available from the server too.

Upvotes: 2

Related Questions