{"record":{"id":"6ebe3a7c183b74b4","repo":"ipfs/kubo","slug":"errnotdht","errorCode":"ErrNotDHT","errorMessage":"routing service is not a DHT","messagePattern":"routing service is not a DHT","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/dht.go","lineNumber":15,"sourceCode":"package commands\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\n\tcmds \"github.com/ipfs/go-ipfs-cmds\"\n\t\"github.com/ipfs/kubo/core/commands/cmdenv\"\n\tpeer \"github.com/libp2p/go-libp2p/core/peer\"\n\trouting \"github.com/libp2p/go-libp2p/core/routing\"\n)\n\nvar ErrNotDHT = errors.New(\"routing service is not a DHT\")\n\nvar DhtCmd = &cmds.Command{\n\tStatus: cmds.Deprecated,\n\tHelptext: cmds.HelpText{\n\t\tTagline:          \"Issue commands directly through the DHT.\",\n\t\tShortDescription: ``,\n\t},\n\n\tSubcommands: map[string]*cmds.Command{\n\t\t\"query\":     queryDhtCmd,\n\t\t\"findprovs\": RemovedDHTCmd,\n\t\t\"findpeer\":  RemovedDHTCmd,\n\t\t\"get\":       RemovedDHTCmd,\n\t\t\"put\":       RemovedDHTCmd,\n\t\t\"provide\":   RemovedDHTCmd,\n\t},\n}\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/dht.go#L1-L33","documentation":"ErrNotDHT is returned by deprecated `ipfs dht` commands when the node's routing service is not a DHT-based router. Kubo can be configured with alternative routing (e.g. delegated HTTP routers, or no DHT), in which case the dht-specific subcommands have nothing to talk to. It is a guard, not a bug, and the same condition is checked as `nd.HasActiveDHTClient()` or `nd.DHT == nil`.","triggerScenarios":"Running `ipfs dht findprovs`, `ipfs dht query` or other dht subcommands on a node where Routing.Type is configured to a non-DHT router (e.g. 'delegated'/'custom') or where no DHT client is active (`!nd.HasActiveDHTClient()`), or `ipfs dht stat` when `nd.DHT` is nil.","commonSituations":"Nodes configured for delegated/no-DHT routing (common for hosted/lightweight nodes); running dht commands against a client-less daemon; old scripts that still use the deprecated `ipfs dht` command tree after switching routing config.","solutions":["Check `ipfs config Routing.Type` and set it to a DHT-backed value (e.g. 'auto'/'dhtclient'/'dhtserver') if DHT access is wanted","Use the `ipfs routing` command family instead of the deprecated `ipfs dht` commands","Verify the daemon actually started with an active DHT client (`ipfs stats dht` or `ipfs routing stat`)"],"exampleFix":"// before\nipfs dht findprovs <cid>   // -> routing service is not a DHT\n// after\nipfs routing findprovs <cid>","handlingStrategy":"fallback","validationCode":"cfg, _ := ipfs.Config()\nif cfg.Routing.Type != \"dhtclient\" && cfg.Routing.Type != \"dhtserver\" && cfg.Routing.Type != \"auto\" { /* fall back to ipfs routing commands */ }","typeGuard":"// client-side: check DHT presence before invoking\nif !node.HasActiveDHTClient() { return ErrNotDHT }","tryCatchPattern":"out, err := runCmd(\"ipfs dht findprovs\", cid)\nif errors.Is(err, ErrNotDHT) || strings.Contains(err.Error(), \"routing service is not a DHT\") {\n    out, err = runCmd(\"ipfs routing findprovs\", cid)\n}","preventionTips":["Prefer `ipfs routing` commands in all new scripts","Check Routing.Type config before using dht-only commands","Note that `ipfs dht` is marked Deprecated in kubo"],"tags":["routing","dht","cli","deprecated"],"backgroundTag":"routing-not-dht","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"}