{"record":{"id":"fb6be27698cc3dd8","repo":"ipfs/kubo","slug":"servehttpapi-constructnode-failed-s","errorCode":null,"errorMessage":"serveHTTPApi: ConstructNode() failed: %s","messagePattern":"serveHTTPApi: ConstructNode\\(\\) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/ipfs/kubo/daemon.go","lineNumber":904,"sourceCode":"\t\tcorehttp.WebUIOption,\n\t\tgatewayOpt,\n\t\tcorehttp.VersionOption(),\n\t\tdefaultMux(\"/debug/vars\"),\n\t\tdefaultMux(\"/debug/pprof/\"),\n\t\tdefaultMux(\"/debug/stack\"),\n\t\tcorehttp.MutexFractionOption(\"/debug/pprof-mutex/\"),\n\t\tcorehttp.BlockProfileRateOption(\"/debug/pprof-block/\"),\n\t\tcorehttp.MetricsScrapingOption(\"/debug/metrics/prometheus\"),\n\t\tcorehttp.LogOption(),\n\t}\n\n\tif len(cfg.Gateway.RootRedirect) > 0 {\n\t\topts = append(opts, corehttp.RedirectOption(\"\", cfg.Gateway.RootRedirect))\n\t}\n\n\tnode, err := cctx.ConstructNode()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"serveHTTPApi: ConstructNode() failed: %s\", err)\n\t}\n\n\t// Buffer channel to prevent deadlock when multiple servers write errors simultaneously\n\terrc := make(chan error, len(listeners))\n\tvar wg sync.WaitGroup\n\n\t// Start all servers and wait for them to be ready before writing api file.\n\t// This prevents race conditions where external tools (like systemd path units)\n\t// see the file and try to connect before servers can accept connections.\n\tif len(listeners) > 0 {\n\t\treadyChannels := make([]chan struct{}, len(listeners))\n\t\tfor i, lis := range listeners {\n\t\t\treadyChannels[i] = make(chan struct{})\n\t\t\tready := readyChannels[i]\n\t\t\twg.Go(func() {\n\t\t\t\terrc <- corehttp.ServeWithReady(node, manet.NetListener(lis), ready, opts...)\n\t\t\t})\n\t\t}","sourceCodeStart":886,"sourceCodeEnd":922,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/cmd/ipfs/kubo/daemon.go#L886-L922","documentation":"serveHTTPApi constructs the full IPFS node (cctx.ConstructNode()) before serving the RPC API; any error during node construction (repo, datastore, blockstore, libp2p host, pnet key) is wrapped with this prefix and aborts daemon startup.","triggerScenarios":"`ipfs daemon` failing during node build: repo version mismatch requiring migration, corrupted datastore, invalid Identity.PrivKey, swarm key issues, or lock held by another process.","commonSituations":"Upgrading kubo across repo versions without `ipfs fsck migrate`; disk full or permissions on the datastore; corrupt config keys like Identity or Swarm; another daemon holding the repo lock.","solutions":["Read the inner error for the root cause; run `ipfs fsck` and repo migrations if a version mismatch is reported","Ensure no other daemon holds the repo lock (`pkill -f 'ipfs daemon'`, remove $IPFS_PATH/repo.lock)","Check datastore disk space and permissions under $IPFS_PATH","Validate config (`ipfs config show`) for malformed Identity/Swarm entries"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// preflight checks\nif _, err := os.Stat(filepath.Join(ipfsPath, \"repo.lock\")); err == nil {\n    // stale lock: ensure no daemon is running, then remove\n}\n// check disk space\nif st, err := os.Statvfs(ipfsPath); err == nil && st.Bavail == 0 { /* disk full */ }","typeGuard":null,"tryCatchPattern":"node, err := cctx.ConstructNode()\nif err != nil {\n    log.Errorf(\"node construction failed: %v\", err)\n    // inspect wrapped cause: migrations, datastore, identity, lock\n    os.Exit(1)\n}","preventionTips":["Run repo migrations after kubo upgrades (`ipfs fsck`)","Monitor datastore disk space","Never run two daemons on the same IPFS_PATH"],"tags":["ipfs","kubo","node-construction","daemon-startup","repo"],"backgroundTag":"node-construction-failed","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"}