How to Fix "The swarm does not have a leader" in Docker Swarm

Recover a Docker Swarm cluster that has lost quorum and reports that the swarm has no leader.

2 min read Updated

If you're running a Docker Swarm cluster and encounter the following error:

bash
$ docker node ls
Error response from daemon: rpc error: code = Unknown desc = The swarm does not have a leader. It's possible that too few managers are online. Make sure more than half of the managers are online.

This means your swarm has lost quorum—there are not enough healthy manager nodes online to elect a leader and maintain consensus.

Recover the Swarm Leader

Force a New Leader Election (Use with Caution)

If you're certain that one of the remaining manager nodes holds the latest valid state, you can force a new leader election by reinitializing the swarm from that node:

bash
docker swarm init --force-new-cluster

⚠️ This command resets the Raft consensus state. Use it only when the majority cannot be restored. Misuse may result in loss of services, secrets, or other swarm metadata.

Rejoin Other Managers

Once the new swarm cluster is created, you can reintegrate the other managers using:

bash
docker swarm join --token <manager-token> <IP>:2377

To retrieve the join token, run:

bash
docker swarm join-token manager

Best Practices for Stability

  • Always deploy an odd number of manager nodes (3, 5, etc.)
  • Ensure manager nodes are spread across different machines or zones
  • Set up monitoring and alerts for manager node health
  • Regularly backup the swarm state from /var/lib/docker/swarm

_

text
_

Search articles

Type to filter articles. Use the arrow keys to move through results and Enter to open one. Press Escape to close.