Service cannot deregister with dead node

We use Consul cluster for 3 servers and 5 clients, and register services through Spring Cloud. However, the services registered on one of those machines should be deregistered automatically when the machine (client) shuts down for some reason. But it does not. Instead, the service shows as healthy based on the last successful health check and does not update anymore for the node being down. The client node shows ‘Agent not live or unreachable.’
Since the API ‘http://{server}:8500/v1/agent/service/deregister/{service_id}’ is inaccessible when the machine is down, and it can only ‘removes a service from the local agent’, how could we deregister those services without restarting Consul?

Hi @zhuopz ,

Welcome to the HashiCorp Forums!

In this situation, you can manually deregister the service directly from the catalog using the v1/catalog API endpoint.

ref: Catalog - HTTP API | Consul | HashiCorp Developer

Hi @Ranjandas,

Thank you for your reply.
You are right, the API “/catalog/deregister” worked!
By the way, could it be deregistered automaticlly?

Take a look at this, this might help: consul deregister_critical_service_after is not woring - Stack Overflow

Sorry, there were a few points I had not mentioned.
I had already used “spring.cloud.consul.discovery.health-check-critical-timeout” in my spring cloud app.this configuration seemed to take effect only for those services registered with the server node. Services registered with the client node, however, could not be deregister automatically(maybe these services should be called “zombie services”), similar to the situation depicted in the image I initially provided.