ipfs/kubo · error

GetClosestPeers not supported: DHT is not available

Error message

GetClosestPeers not supported: DHT is not available

What it means

'ipfs routing findpeer/findprovs' style queries need a DHT, but this node has no DHT client (Routing.Type is delegated or none, so node.DHTClient is nil). The routing API falls through to this explicit failure instead of silently returning nothing.

Source

Thrown at core/corehttp/routing.go:115

	}

	// The caller guarantees that name matches the record. This is double checked
	// by the internals of PutValue.
	return r.n.Routing.PutValue(ctx, string(name.RoutingKey()), raw)
}

func (r *contentRouter) GetClosestPeers(ctx context.Context, key cid.Cid) (iter.ResultIter[*types.PeerRecord], error) {
	// Per the spec, if the peer ID is empty, we should use self.
	if key == cid.Undef {
		return nil, errors.New("GetClosestPeers key is undefined")
	}

	keyStr := string(key.Hash())
	var peers []peer.ID
	var err error

	if r.n.DHTClient == nil {
		return nil, fmt.Errorf("GetClosestPeers not supported: DHT is not available")
	}

	switch dhtClient := r.n.DHTClient.(type) {
	case *dual.DHT:
		// Only use WAN DHT for public HTTP Routing API.
		// LAN DHT contains private network peers that should not be exposed publicly.
		if dhtClient.WAN == nil {
			return nil, fmt.Errorf("GetClosestPeers not supported: WAN DHT is not available")
		}
		peers, err = dhtClient.WAN.GetClosestPeers(ctx, keyStr)
	case *fullrt.FullRT:
		peers, err = dhtClient.GetClosestPeers(ctx, keyStr)
	case *dht.IpfsDHT:
		peers, err = dhtClient.GetClosestPeers(ctx, keyStr)
	default:
		return nil, fmt.Errorf("GetClosestPeers not supported for DHT type %T", r.n.DHTClient)
	}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Run the node with Routing.Type unset (autorrouting with DHT) or 'dht' so a DHT client exists
  2. For content routing without a DHT, use the delegated HTTP router via 'ipfs routing' with Routing.Type=delegated and an appropriate command that supports it
  3. Check Routers config in docs/config.md for enabling HTTP delegated routers
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at core/corehttp/routing.go:115 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/690270a26ef745e8. Report an issue: GitHub.