Clean up registered Vault instances in Consul

I am using Consul v1.20.0 and Vault v1.18.0.

Before today, my Vault configuration used hostnames. As such, the Vault service in Consul references the hosts’ names.
I had to change the Vault configuration to use IP Addresses (for more information, please see .consul DNS oddity - #3 by blake).

Since the change, all Vault service IP addresses are showing as healthy, but Vault hostnames are showing as failing.
I expected that the hostnames would not be there:

I tried deleting the files under /opt/consul/data but couldn’t get Consul started again.

How can I remove these “dead” nodes?

Thank you

1 Like

Hi @originaltrini0,

To deregister those stale instances, all you have to do is, log in to the respective nodes and run the following command:

# replace XX with the correct number (01, 02, 03)
consul services deregister -id vault:prod-core-servicesXX:8200

You must deregister each service from the nodes where they were running, or else the command will error.

Ref: Commands: Services Deregister | Consul | HashiCorp Developer

@Ranjandas:

That worked out perfectly!

Thank you

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.