Deregister service from consul

I am facing issue while trying to remove/deregister services not used any more from consul. When I run deregister command suggested in consul docs, I am facing this error.

[root@frame-consul10-242-56-92 centos]# consul catalog services | grep rabbitmq
**rabbitmq**
**rabbitmq** -sidecar-proxy

root@frame-consul10-242-56-92 centos]# consul services deregister -id=rabbitmq
Error registering service "": Unexpected response code: 500 (Unknown service {"rabbitmq" {}})

Any advice how I can deregister unused servise from consul?

Hi @tmiroslav

Few questions for you:

  1. What are the **'s in your service name output?
  2. Whats the Consul version you are running?
  3. Are you deregistering the service from the same node from which it was registered? This is a requirement from Consul

The services deregister command deregisters a service with the local agent. Note that this command can only deregister services that were registered with the agent specified (defaults to the local agent) and is meant to be paired with services register .

Ref: Commands: Services Deregister | Consul by HashiCorp

Hi! Please look below for my answers:
1.That’s something occurs while coping. Somehow I could not edit question and correct that. Service name is:

[root@frame-consul10-242-56-92 centos]# consul catalog services | grep rabbitmq
rabbitmq
rabbitmq-sidecar-proxy

  1. Consul version is v1.8.3
  2. I have 3 nodes running in consul cluster. I am not sure on which one it was registered at the time. But, I have tried deregister command from each consul node in the cluster, and it failed with same error message I pasted above. In the same time, I was using consul bootstrap token privilege while doing deregistration.

Thank yuo!

Hi,

What I realized meanwhile is that service would be automatically removed from consul server after stopping consul agent in client side. I have been trying to do deregistration while consul agent was active in client (RabbitMQ in my case) node, and was facing issue described above.

Hi @tmiroslav,

Do you have ACLs enabled on this cluster?

Hi @Ranjandas

Yes, I do have.

I am wondering whether its related to this bug: https://github.com/hashicorp/consul/issues/9577.

Could you have a look at it and see if this is what you are having?

@Ranjandas

Some things look similar, but I could not say that it’s same issue. There is no Nomad in our configuration. Also, no ACL issue I could see in the logs while experiencing the problem.
Also, in our case, there was no problem/incident happened in the network. We are just moving out from using consul agent in RabbitMQ, and just want regularly to remove RabbitMQ service from Consul. But, as I sad above, looks like RabbitMQ service was automatically deregistered from Consul server after stopping Consul agent in client side. Before that, I could not do deregistration in Consul server, while Consul agent in RabbitMQ was running.