0
votes

I was trying to run consul in vagrant using the following comman

consul agent -dev -advertise 172.20.20.31

but it showing following error message

failed to get conn: dial tcp 127.0.0.1:0->172.20.20.31:8300: connect: invalid argument"

as a result when i connect form my local machine to this ip and run consul ui mode it showing

500 (The backend responded with an error)

my vagrant file is as follow:

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.define "centos-consul" do |cs|
    cs.vm.hostname = "centos-consul"
    cs.vm.network "private_network",ip:"172.20.20.31"
  end
end

and connect file is as

{
        "ui": true,
        "retry_join": ["172.20.20.31"],
        "advertise_addr": "172.20.20.01",
        "data_dir": "/tmp/consul/self"
}

I am using consul 1.7.2 in mac os and Vagrant 2.2.7 centos7

I am at a lost what i did wrong. so any suggestion will be helpful.

1

1 Answers

0
votes

According to the documentation, the error you are getting is the result of IP address 172.20.20.31 being not routable from your Vagrant box.

-advertise - The advertise address is used to change the address that we advertise to other nodes in the cluster. By default, the -bind address is advertised. However, in some cases, there may be a routable address that cannot be bound. This flag enables gossiping a different address to support this. If this address is not routable, the node will be in a constant flapping state as other nodes will treat the non-routability as a failure. In Consul 1.0 and later this can be set to a go-sockaddr template.