`consul members` fails because it is querying the wrong port, how to tell it to use the right port?

I’m setting up a 3 node Consul cluster to use as Vault’s data backend. Since the Vault docs recommend using custom ports so you don’t end up messing with a non-Vault instance of Consul, I configured my ports like so:

ports {
  dns = 7600
  http = 7500
  serf_lan = 7301
  serf_wan = 7302
  server = 7300
  sidecar_min_port = 21000
  sidecar_max_port = 21255

I seem to have started it successfully if the output of journalctl is to be believed, but when I try to use the cli, it just doesn’t work.

As a specific example, here is what I get for my consul members output:

Error retrieving members: Get "": dial tcp connect: connection refused

Why isn’t it using port 7500 like in the config file?

If I try consul members -config-dir=/etc/consul.d I get this message: flag provided but not defined: -config-dir.

How do I get the Consul cli tool to work?

My nodes are running Ubuntu 18.04 and Consul is installed via the HashiCorp repos.

Thanks in advance!

Hi @jerrac,

The configuration files are only used when you run Consul as a daemon using consul agent. When the consul command is used in any other context, the configuration files are ignored.

You can use the -http-addr flag or CONSUL_HTTP_ADDR environment variable to change address that will be used to communicate with the Consul API. For example:

# Specify the HTTP API address using the -http-addr flag
$ consul members -http-addr=

# Specify the HTTP API address using the CONSUL_HTTP_ADDR environment variable
$ consul members

Thanks. That’s exactly what I needed. :slight_smile: