Can't deregister service with name "http://host:port/"

Hello All,
I made a mistake during registration of my service and it looks like stf_app:http://something.abc.com:3100/ now
I need to remove it, but neither consul services deregister, nor API, nor ansible consul module (which was used for registration) do not work:

  • consul services deregister --token=123 -id=stf_app:http://something.abc.com:3100/ : Error registering service “”: Unexpected response code: 405 (method GET not allowed)
  • ansible playbook: msg: 500 Unknown service {“stf_app:http:/something.abc.com:3100/” {}}
  • curl --request PUT --data @deregister_stf.json http://127.0.0.1:8500/v1/catalog/deregister ( { "Datacenter": "dc1", "ServiceID": "stf_app", "Node": "node.abc.com" } ) : rpc error making call: Unknown service ‘stf_app’

There is some magic how Consul replaces http:// to http:/ in my case and this happens only if I put :3100/ at the end.

I’ve checked similar topics on the net, but nothing seems to be related to my case.

Does anyone have a clue how to fix this? Appreciate any help.

Hi @vyakovlev-hw,

Could you check that the ID in the output of curl http://localhost:8500/v1/agent/service/stf_app (when queried from node.abc.com) matches the ID of the service that you’re trying to de-register?

If not, try the de-registration with the ID returned from the command. It should successfully remove the service.

Hello @blake, thanks for proposed solution and sorry for the late response.
Unfortunately, it doesn’t work.

$ curl http://localhost:8500/v1/agent/service/stf_app
unknown service ID: stf_app

$ curl --request GET http://127.0.0.1:8500/v1/catalog/services | python -m json.tool | grep ‘stf_app’ -A1 -B1
“serviceA”: ,
“stf_app”: ,
“serviceB”: [

$ cat deregister_stf.json
{
“Datacenter”: “dc1”,
“ServiceID”: “stf_app”,
“Node”: “node.abc.com
}

$ curl --request PUT --data @deregister_stf.json http://127.0.0.1:8500/v1/catalog/deregister
rpc error making call: Unknown service ‘stf_app’

Probably, I’m doing something wrong? Appreciate any help.