{"record":{"id":"690270a26ef745e8","repo":"ipfs/kubo","slug":"getclosestpeers-not-supported-dht-is-not-availabl","errorCode":null,"errorMessage":"GetClosestPeers not supported: DHT is not available","messagePattern":"GetClosestPeers not supported: DHT is not available","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/corehttp/routing.go","lineNumber":115,"sourceCode":"\t}\n\n\t// The caller guarantees that name matches the record. This is double checked\n\t// by the internals of PutValue.\n\treturn r.n.Routing.PutValue(ctx, string(name.RoutingKey()), raw)\n}\n\nfunc (r *contentRouter) GetClosestPeers(ctx context.Context, key cid.Cid) (iter.ResultIter[*types.PeerRecord], error) {\n\t// Per the spec, if the peer ID is empty, we should use self.\n\tif key == cid.Undef {\n\t\treturn nil, errors.New(\"GetClosestPeers key is undefined\")\n\t}\n\n\tkeyStr := string(key.Hash())\n\tvar peers []peer.ID\n\tvar err error\n\n\tif r.n.DHTClient == nil {\n\t\treturn nil, fmt.Errorf(\"GetClosestPeers not supported: DHT is not available\")\n\t}\n\n\tswitch dhtClient := r.n.DHTClient.(type) {\n\tcase *dual.DHT:\n\t\t// Only use WAN DHT for public HTTP Routing API.\n\t\t// LAN DHT contains private network peers that should not be exposed publicly.\n\t\tif dhtClient.WAN == nil {\n\t\t\treturn nil, fmt.Errorf(\"GetClosestPeers not supported: WAN DHT is not available\")\n\t\t}\n\t\tpeers, err = dhtClient.WAN.GetClosestPeers(ctx, keyStr)\n\tcase *fullrt.FullRT:\n\t\tpeers, err = dhtClient.GetClosestPeers(ctx, keyStr)\n\tcase *dht.IpfsDHT:\n\t\tpeers, err = dhtClient.GetClosestPeers(ctx, keyStr)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"GetClosestPeers not supported for DHT type %T\", r.n.DHTClient)\n\t}\n","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/corehttp/routing.go#L97-L133","documentation":"'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.","triggerScenarios":"Thrown at core/corehttp/routing.go:115 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the node with Routing.Type unset (autorrouting with DHT) or 'dht' so a DHT client exists","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","Check Routers config in docs/config.md for enabling HTTP delegated routers"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}