{"record":{"id":"b85a13a619bf567e","repo":"ipfs/kubo","slug":"ipfs-api-address-could-not-be-found","errorCode":null,"errorMessage":"ipfs api address could not be found","messagePattern":"ipfs api address could not be found","errorType":"exception","errorClass":"ErrApiNotFound","httpStatus":null,"severity":"error","filePath":"client/rpc/api.go","lineNumber":39,"sourceCode":"\tiface \"github.com/ipfs/kubo/core/coreiface\"\n\tcaopts \"github.com/ipfs/kubo/core/coreiface/options\"\n\t\"github.com/ipfs/kubo/misc/fsutil\"\n\tdagpb \"github.com/ipld/go-codec-dagpb\"\n\t_ \"github.com/ipld/go-ipld-prime/codec/dagcbor\"\n\t\"github.com/ipld/go-ipld-prime/node/basicnode\"\n\tma \"github.com/multiformats/go-multiaddr\"\n\tmanet \"github.com/multiformats/go-multiaddr/net\"\n)\n\nconst (\n\tDefaultPathName = \".ipfs\"\n\tDefaultPathRoot = \"~/\" + DefaultPathName\n\tDefaultApiFile  = \"api\"\n\tEnvDir          = \"IPFS_PATH\"\n)\n\n// ErrApiNotFound if we fail to find a running daemon.\nvar ErrApiNotFound = errors.New(\"ipfs api address could not be found\")\n\n// HttpApi implements github.com/ipfs/interface-go-ipfs-core/CoreAPI using\n// IPFS HTTP API.\n//\n// For interface docs see\n// https://godoc.org/github.com/ipfs/interface-go-ipfs-core#CoreAPI\ntype HttpApi struct {\n\turl         string\n\thttpcli     http.Client\n\tHeaders     http.Header\n\tapplyGlobal func(*requestBuilder)\n\tipldDecoder *legacy.Decoder\n\tversionMu   sync.Mutex\n\tversion     *semver.Version\n}\n\n// NewLocalApi tries to construct new HttpApi instance communicating with local\n// IPFS daemon","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/client/rpc/api.go#L21-L57","documentation":"ErrApiNotFound is the sentinel error returned by NewPathApi when the API file (~/.ipfs/api by default, or $IPFS_PATH/api) does not exist. The api file is written by a running daemon and contains its multiaddress, so a missing file means no local daemon appears to be running or the path root points somewhere else.","triggerScenarios":"Creating a client with rpc.NewLocalApi() / NewPathApi() while no daemon is running; IPFS_PATH pointing at a directory with no initialized repo or api file; daemon started with a custom repo path but the client using the default path.","commonSituations":"Scripts that call the RPC client before `ipfs daemon` is started; DAEMON started with IPFS_PATH set but client without it (or vice versa); repo initialized but daemon never started so no api file was written; macOS/Windows users whose repo lives in a non-default location.","solutions":["Start the daemon first: run `ipfs daemon` and wait until it prints the API address","Point the client at the daemon explicitly with NewApi(url) or the multiaddress from `$IPFS_PATH/api` instead of path discovery","Ensure IPFS_PATH matches on both daemon and client (env var must be set for both processes)","Verify the api file exists: `cat $(ipfs config Identity.PeerID 2>/dev/null; echo $IPFS_PATH)/api` or `ls ~/.ipfs/api`; use `errors.Is(err, rpc.ErrApiNotFound)` to branch on this case"],"exampleFix":"// before\napi, err := rpc.NewPathApi() // fails when daemon not running\nif err != nil { return err }\n// after\napi, err := rpc.NewPathApi()\nif errors.Is(err, rpc.ErrApiNotFound) {\n    return fmt.Errorf(\"start the daemon first: 'ipfs daemon'\")\n}","handlingStrategy":"fallback","validationCode":"apiFile := filepath.Join(os.Getenv(\"IPFS_PATH\"), \"api\")\nif apiFile == \"api\" || apiFile == \"\" { apiFile = filepath.Join(os.Getenv(\"HOME\"), \".ipfs\", \"api\") }\nif _, err := os.Stat(apiFile); os.IsNotExist(err) {\n    // daemon not running or wrong IPFS_PATH\n}","typeGuard":"func apiAvailable() bool {\n    p := os.Getenv(\"IPFS_PATH\")\n    if p == \"\" { p = filepath.Join(os.Getenv(\"HOME\"), \".ipfs\") }\n    _, err := os.Stat(filepath.Join(p, \"api\"))\n    return err == nil\n}","tryCatchPattern":"api, err := rpc.NewPathApi()\nif errors.Is(err, rpc.ErrApiNotFound) {\n    // fall back to spawning the daemon or an explicit address\n    api, err = rpc.NewApi(\"/ip4/127.0.0.1/tcp/5001\")\n}\nif err != nil { return err }","preventionTips":["Start `ipfs daemon` before creating a path-based client","Keep IPFS_PATH consistent between daemon and client","Use explicit addresses (NewApi) in scripts instead of path discovery"],"tags":["go","ipfs","rpc","daemon","discovery"],"backgroundTag":"daemon-not-running","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"}