{"record":{"id":"24c12e855bd8433c","repo":"ipfs/kubo","slug":"listing-keys-failed-w","errorCode":null,"errorMessage":"listing keys failed: %w","messagePattern":"listing keys failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/keystore.go","lineNumber":603,"sourceCode":"\t},\n\tOptions: []cmds.Option{\n\t\tcmds.BoolOption(\"l\", \"Show extra information about keys.\"),\n\t\tke.OptionIPNSBase,\n\t},\n\tRun: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {\n\t\tkeyEnc, err := ke.KeyEncoderFromString(req.Options[ke.OptionIPNSBase.Name()].(string))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot get key encoder: %w\", err)\n\t\t}\n\n\t\tapi, err := cmdenv.GetApi(env, req)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tkeys, err := api.Key().List(req.Context)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"listing keys failed: %w\", err)\n\t\t}\n\n\t\tlist := make([]KeyOutput, 0, len(keys))\n\n\t\tfor _, key := range keys {\n\t\t\tlist = append(list, KeyOutput{\n\t\t\t\tName: key.Name(),\n\t\t\t\tId:   keyEnc.FormatID(key.ID()),\n\t\t\t})\n\t\t}\n\n\t\treturn cmds.EmitOnce(res, &KeyOutputList{list})\n\t},\n\tEncoders: cmds.EncoderMap{\n\t\tcmds.Text: keyOutputListEncoders(),\n\t},\n\tType: KeyOutputList{},\n}","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/keystore.go#L585-L621","documentation":"The Key().List RPC call made by `ipfs key list` failed — kubo could not enumerate the node's keypairs. The wrapped error is the underlying cause, typically the daemon is unreachable or the repo/keystore could not be read.","triggerScenarios":"`ipfs key list` while the daemon is not running (no API at $IPFS_PATH/api), wrong `--api` target, the daemon shut down mid-call, or repo/keystore read failure on the node side.","commonSituations":"Forgetting to start `ipfs daemon` before CLI commands; pointing at the wrong port with `--api`; node crash or lock contention in scripts.","solutions":["Start the daemon: `ipfs daemon`, then retry `ipfs key list`","Check you target the right node: verify $IPFS_PATH and `--api` address / `ipfs --api=/ip4/127.0.0.1/tcp/5001 key list`","Read the wrapped `%w` cause in the full error output and fix that underlying issue (connection refused, repo locked, etc.)","Confirm the API address in `ipfs config Addresses.API` matches what the client uses"],"exampleFix":"// before\n$ ipfs key list\nError: listing keys failed: connection refused\n// after\n$ ipfs daemon &\n$ ipfs key list","handlingStrategy":"try-catch","validationCode":"// ensure the daemon API is reachable before running key commands\nresp, err := http.Post(apiAddr+\"/api/v0/id\", \"\", nil)\nif err != nil {\n    return fmt.Errorf(\"daemon not reachable at %s; start it with `ipfs daemon`\", apiAddr)\n}\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":"if err := runKeyList(); err != nil {\n    var wrapped interface{ Unwrap() error }\n    if errors.As(err, &unwrapped) && strings.Contains(unwrapped.Error(), \"connection refused\") {\n        // start daemon or fix --api address, then retry\n    }\n}","preventionTips":["Start `ipfs daemon` before CLI key commands in scripts","Pin the API address with `--api` or `ipfs --api` rather than relying on defaults","Health-check the API endpoint (`ipfs id`) at script start","Check `Addresses.API` config matches the port your client expects"],"tags":["keystore","rpc","daemon","network","key-list"],"backgroundTag":"daemon-connection-refused","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"}