Error connecting to Consul agent: dial tcp 127.0.0.1:8400: getsockopt: connection refused

1,604 views
Skip to first unread message

Roger Hill

unread,
May 12, 2016, 2:02:14 PM5/12/16
to Consul
I have two consul servers running in a cluster. When I run $ consul members command on one, it works fine, but on the other it gives the error:

Error connecting to Consul agent: dial tcp 127.0.0.1:8400: getsockopt: connection refused

On the second server I have to use the option --rpc-addr to get the results. Why this discrepancy? Any comments?


Host1:

Launch command: 
$ consul agent -server -data-dir /var/consul -node=Host1 -bind=10.244.44.1 -config-dir=/etc consul.d

Members command: 

[root@Host1 server]# consul members
Node   Address            Status  Type    Build  Protocol  DC
Host1  10.244.44.1:8301  alive   server  0.6.3  2         dc1
Host2  10.244.44.2:8301  alive   server  0.6.3  2         dc1


Host2:

Launch command:
$  consul agent -server -data-dir /tmp/consul -node=Host2 -bind=10.244.44.2 -config-dir /etc consul.d -client=10.244.44.2

Members command: 
[root@Host2 ssl]# consul members -detailed
Error connecting to Consul agent: dial tcp 127.0.0.1:8400: getsockopt: connection refused


[root@Host2 ssl]# consul members --rpc-addr=10.244.44.2:8400
Node   Address            Status  Type    Build  Protocol  DC
Host1  10.244.44.1:8301  alive   server  0.6.3  2         dc1
Host2  10.244.44.2:8301  alive   server  0.6.3  2         dc1



Bright Zheng

unread,
Aug 17, 2016, 5:44:59 AM8/17/16
to Consul
I got this error also.
My finding was: once the agent enables the parameter of -client, we can issue commands like "consul members" or "consul join" in other agents where "-client" was not used.

So in you case, you can issue all the above-mentioned commands in Host1, instead of Host2.
Have a try!

Bright
Reply all
Reply to author
Forward
0 new messages