Search code examples
consul

Error connecting to Consul agent


I have a consul server running on ubuntu box via vagrant and virtual box It appears to be running correctly:

running server

I then ssh onto the box and run:

consul members

but I get this output:

enter image description here

What am I doing wrong? I cant figure this out as I am following consul tutorial, and it seems to have no issue with this

Adding config.json file

{
    "bootstrap": true,
    "server": true,
    "datacenter": "dc1",
    "data_dir": "/var/consul",
    "encrypt": "Dt3P9SpKGAR/DIUN1cDirg==",
    "log_level": "INFO",
    "enable_syslog": true,
    "bind_addr": "172.20.20.10",
    "client_addr": "172.20.20.10"
}

Solution

  • Consul defaults to the client address of 127.0.0.1, but you have configured your server to listen on 172.20.20.10 for clients.

    You'll need to put the option -rpc-addr to your command line invocation as well to make it work:

    consul members -rpc-addr=172.20.20.10:8400
    

    I'm also the author of an example Consul setup with Vagrant and Saltstack, maybe you want to have a look at the Github repository.