{"record":{"id":"011f50bb33866b73","repo":"ipfs/kubo","slug":"invalid-configuration-bitswap-libp2penabled-and-h","errorCode":null,"errorMessage":"invalid configuration: Bitswap.Libp2pEnabled and HTTPRetrieval.Enabled are both disabled, unable to initialize Bitswap","messagePattern":"invalid configuration: Bitswap\\.Libp2pEnabled and HTTPRetrieval\\.Enabled are both disabled, unable to initialize Bitswap","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/node/bitswap.go","lineNumber":125,"sourceCode":"\t\t\t\thttpCfg.Allowlist != nil,\n\t\t\t\thttpCfg.Denylist != nil,\n\t\t\t)\n\n\t\t\tbitswapHTTP := httpnet.New(in.Host,\n\t\t\t\thttpnet.WithHTTPWorkers(int(httpCfg.NumWorkers.WithDefault(config.DefaultHTTPRetrievalNumWorkers))),\n\t\t\t\thttpnet.WithAllowlist(httpCfg.Allowlist),\n\t\t\t\thttpnet.WithDenylist(httpCfg.Denylist),\n\t\t\t\thttpnet.WithInsecureSkipVerify(httpCfg.TLSInsecureSkipVerify.WithDefault(config.DefaultHTTPRetrievalTLSInsecureSkipVerify)),\n\t\t\t\thttpnet.WithMaxBlockSize(int64(maxBlockSize)),\n\t\t\t\thttpnet.WithUserAgent(version.GetUserAgentVersion()),\n\t\t\t\thttpnet.WithMetricsLabelsForEndpoints(httpCfg.Allowlist),\n\t\t\t\thttpnet.WithConnectEventManager(connEvtMgr),\n\t\t\t)\n\t\t\tbitswapNetworks = network.New(in.Host.Peerstore(), bitswapLibp2p, bitswapHTTP)\n\t\t} else if libp2pEnabled {\n\t\t\tbitswapNetworks = bitswapLibp2p\n\t\t} else {\n\t\t\treturn nil, errors.New(\"invalid configuration: Bitswap.Libp2pEnabled and HTTPRetrieval.Enabled are both disabled, unable to initialize Bitswap\")\n\t\t}\n\n\t\t// Kubo uses own, customized ProviderQueryManager\n\t\tin.BitswapOpts = append(in.BitswapOpts, bitswap.WithClientOption(client.WithDefaultProviderQueryManager(false)))\n\t\tvar maxProviders int = DefaultMaxProviders\n\n\t\tvar bcDisposition string\n\t\tif in.Cfg.Internal.Bitswap != nil {\n\t\t\tmaxProviders = int(in.Cfg.Internal.Bitswap.ProviderSearchMaxResults.WithDefault(DefaultMaxProviders))\n\t\t\tif in.Cfg.Internal.Bitswap.BroadcastControl != nil {\n\t\t\t\tbcCfg := in.Cfg.Internal.Bitswap.BroadcastControl\n\t\t\t\tbcEnable := bcCfg.Enable.WithDefault(config.DefaultBroadcastControlEnable)\n\t\t\t\tin.BitswapOpts = append(in.BitswapOpts, bitswap.WithClientOption(client.BroadcastControlEnable(bcEnable)))\n\t\t\t\tif bcEnable {\n\t\t\t\t\tbcDisposition = \"enabled\"\n\t\t\t\t\tbcMaxPeers := int(bcCfg.MaxPeers.WithDefault(config.DefaultBroadcastControlMaxPeers))\n\t\t\t\t\tin.BitswapOpts = append(in.BitswapOpts, bitswap.WithClientOption(client.BroadcastControlMaxPeers(bcMaxPeers)))\n","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/node/bitswap.go#L107-L143","documentation":"Kubo's Bitswap client requires at least one transport network to retrieve blocks: the libp2p bitswap network and/or the HTTP retrieval network. During node construction (fx dependency injection in core/node/bitswap.go), if both Bitswap.Libp2pEnabled and HTTPRetrieval.Enabled are disabled, there is no way to build the bitswap network stack and the constructor fails, aborting daemon startup.","triggerScenarios":"Starting `ipfs daemon` with a config where `Bitswap.Libp2pEnabled=false` (or its default-resolved value) and `HTTPRetrieval.Enabled=false` are both set; the Bitswap fx constructor hits the else branch and returns this error before any bitswap client is created.","commonSituations":"Operators who disable libp2p bitswap (e.g. wanting HTTP-only retrieval) then also turn off HTTPRetrieval believing it is unused; scripted config hardening that zeroes out all retrieval transports; misreading Bitswap.ServerEnabled (server off is fine) as also disabling the client.","solutions":["Re-enable at least one retrieval transport: `ipfs config --json Bitswap.Libp2pEnabled true` (the default) or `ipfs config --json HTTPRetrieval.Enabled true`.","If you only want HTTP retrieval, keep Libp2pEnabled=false but set HTTPRetrieval.Enabled=true with an Allowlist in HTTPRetrieval config.","If you meant to disable serving blocks only, use `ipfs config --json Bitswap.ServerEnabled false` instead of disabling the client transports.","Review the effective config with `ipfs config Bitswap` and `ipfs config HTTPRetrieval` before restarting the daemon."],"exampleFix":"// before (config.json)\n{\"Bitswap\": {\"Libp2pEnabled\": false}, \"HTTPRetrieval\": {\"Enabled\": false}}\n\n// after\n{\"Bitswap\": {\"Libp2pEnabled\": false}, \"HTTPRetrieval\": {\"Enabled\": true, \"Allowlists\": {\"Allowlist\": [\"example.com\"]}}}","handlingStrategy":"validation","validationCode":"// Before starting the daemon, verify at least one bitswap transport is enabled\nimport \"github.com/ipfs/kubo/config\"\ncfg, err := repo.Config()\nif err != nil { return err }\nlibp2p := cfg.Bitswap.Libp2pEnabled.WithDefault(config.DefaultBitswapLibp2pEnabled)\nhttp := cfg.HTTPRetrieval.Enabled.WithDefault(config.DefaultHTTPRetrievalEnabled)\nif !libp2p && !http {\n    return fmt.Errorf(\"at least one of Bitswap.Libp2pEnabled or HTTPRetrieval.Enabled must be true\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never disable both Bitswap.Libp2pEnabled and HTTPRetrieval.Enabled; Bitswap.ServerEnabled=false is the correct way to stop serving blocks.","After scripted config changes, run `ipfs config Bitswap` and `ipfs config HTTPRetrieval` to sanity-check before restart.","Test config changes on a throwaway IPFS_PATH (`IPFS_PATH=$(mktemp -d) ipfs daemon`) before applying to production."],"tags":["config","bitswap","startup","kubo"],"backgroundTag":"invalid-bitswap-transport-config","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"}