Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing default consul http port

Tags:

consul

I need to change the default http port because another application is using 8500 already.

This command works:

consul info -http-addr=http://127.0.0.1:18500

I can't figure out what config setting this equals to in a config file.

Here are my current settings:

datacenter = "test_test"
data_dir = "/opt/consul"
encrypt = "**********"
performance {
  raft_multiplier = 1
}
ports {
  http = 18500
  dns = 18600
  server = 18300
}
addresses {
  http = "127.0.0.1"
}
retry_join = ["10.60.0.5"]`

Error message when I run the join or info command:

Error querying agent: Get http://127.0.0.1:8500/v1/agent/self: dial tcp 127.0.0.1:8500: connect: connection refused

like image 398
rmp Avatar asked May 27 '26 19:05

rmp


1 Answers

If you use:

{
    "ports": {
        "http": 18500
    }
}

Then consul by default will bind to localhost:

==> Log data will now stream in as it occurs:

    2019/02/19 17:28:23 [INFO] raft: Initial configuration (index=1): [{Suffrage:Voter ID:4887467c-c84b-15b4-66f7-ad3f822631e0 Address:172.17.0.2:8300}]
    2019/02/19 17:28:23 [INFO] raft: Node at 172.17.0.2:8300 [Follower] entering Follower state (Leader: "")
    2019/02/19 17:28:23 [INFO] serf: EventMemberJoin: b884fe85d115.dc1 172.17.0.2
    2019/02/19 17:28:23 [INFO] serf: EventMemberJoin: b884fe85d115 172.17.0.2
    2019/02/19 17:28:24 [INFO] consul: Adding LAN server b884fe85d115 (Addr: tcp/172.17.0.2:8300) (DC: dc1)
    2019/02/19 17:28:24 [INFO] consul: Handled member-join event for server "b884fe85d115.dc1" in area "wan"
    2019/02/19 17:28:24 [WARN] agent/proxy: running as root, will not start managed proxies
    2019/02/19 17:28:24 [INFO] agent: Started DNS server 127.0.0.1:8600 (tcp)
    2019/02/19 17:28:24 [INFO] agent: Started DNS server 127.0.0.1:8600 (udp)
    2019/02/19 17:28:24 [INFO] agent: Started HTTP server on 127.0.0.1:18500 (tcp)

Obviously, anyone from other nodes can't connect to your bootstrap server.

You should configure address and port:

{
    "addresses": {
        "http": "0.0.0.0"
    },    
    "ports": {
        "http": 18500
    }
}

Now you can see binding for any IP 0.0.0.0/0

==> Log data will now stream in as it occurs:

    2019/02/19 17:35:11 [INFO] raft: Initial configuration (index=1): [{Suffrage:Voter ID:ef42f35f-7505-d1fc-3f91-16f144d91fc6 Address:172.17.0.2:8300}]
    2019/02/19 17:35:11 [INFO] raft: Node at 172.17.0.2:8300 [Follower] entering Follower state (Leader: "")
    2019/02/19 17:35:11 [INFO] serf: EventMemberJoin: ac34230483e0.dc1 172.17.0.2
    2019/02/19 17:35:11 [INFO] serf: EventMemberJoin: ac34230483e0 172.17.0.2
    2019/02/19 17:35:11 [INFO] agent: Started DNS server 127.0.0.1:8600 (udp)
    2019/02/19 17:35:11 [WARN] agent/proxy: running as root, will not start managed proxies
    2019/02/19 17:35:11 [INFO] consul: Adding LAN server ac34230483e0 (Addr: tcp/172.17.0.2:8300) (DC: dc1)
    2019/02/19 17:35:11 [INFO] agent: Started DNS server 127.0.0.1:8600 (tcp)
    2019/02/19 17:35:11 [INFO] consul: Handled member-join event for server "ac34230483e0.dc1" in area "wan"
    2019/02/19 17:35:11 [INFO] agent: Started HTTP server on [::]:18500 (tcp)
like image 141
ozlevka Avatar answered Jun 03 '26 01:06

ozlevka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!