{"record":{"id":"9e8aa39424b114a0","repo":"ipfs/kubo","slug":"autoconf-cannot-use-the-default-mainnet-url-s-o","errorCode":null,"errorMessage":"AutoConf cannot use the default mainnet URL (%s) on a private network (swarm.key or LIBP2P_FORCE_PNET detected). Either disable AutoConf by setting AutoConf.Enabled=false, or configure AutoConf.URL to point to a configuration service specific to your private swarm","messagePattern":"AutoConf cannot use the default mainnet URL \\((.+?)\\) on a private network \\(swarm\\.key or LIBP2P_FORCE_PNET detected\\)\\. Either disable AutoConf by setting AutoConf\\.Enabled=false, or configure AutoConf\\.URL to point to a configuration service specific to your private swarm","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/autoconf_client.go","lineNumber":73,"sourceCode":"\t\tautoconf.WithRefreshInterval(refreshInterval.WithDefault(DefaultAutoConfRefreshInterval)),\n\t\tautoconf.WithFallback(autoconf.GetMainnetFallbackConfig),\n\t\tautoconf.WithURL(url),\n\t}\n\n\treturn autoconf.NewClient(options...)\n}\n\n// ValidateAutoConfWithRepo validates that autoconf setup is correct at daemon startup with repo access\nfunc ValidateAutoConfWithRepo(cfg *Config, swarmKeyExists bool) error {\n\tif !cfg.AutoConf.Enabled.WithDefault(DefaultAutoConfEnabled) {\n\t\t// AutoConf is disabled, check for \"auto\" values and warn\n\t\treturn validateAutoConfDisabled(cfg)\n\t}\n\n\t// Check for private network with default mainnet URL\n\turl := cfg.AutoConf.URL.WithDefault(DefaultAutoConfURL)\n\tif swarmKeyExists && url == DefaultAutoConfURL {\n\t\treturn fmt.Errorf(\"AutoConf cannot use the default mainnet URL (%s) on a private network (swarm.key or LIBP2P_FORCE_PNET detected). Either disable AutoConf by setting AutoConf.Enabled=false, or configure AutoConf.URL to point to a configuration service specific to your private swarm\", DefaultAutoConfURL)\n\t}\n\n\t// Further validation will happen lazily when config is accessed\n\treturn nil\n}\n\n// validateAutoConfDisabled checks for \"auto\" values when AutoConf is disabled and logs errors\nfunc validateAutoConfDisabled(cfg *Config) error {\n\thasAutoValues := false\n\tvar errors []string\n\n\t// Check Bootstrap\n\tif slices.Contains(cfg.Bootstrap, AutoPlaceholder) {\n\t\thasAutoValues = true\n\t\terrors = append(errors, \"Bootstrap contains 'auto' but AutoConf.Enabled=false\")\n\t}\n\n\t// Check DNS.Resolvers","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/config/autoconf_client.go#L55-L91","documentation":"ValidateAutoConfWithRepo refuses to start when the node is on a private network (a swarm.key exists or LIBP2P_FORCE_PNET is set) while AutoConf is enabled with the default mainnet URL. Fetching shared publicnet configuration would leak or misconfigure a private swarm, so kubo forces an explicit choice: disable AutoConf or point AutoConf.URL at a private configuration service.","triggerScenarios":"Starting the daemon (via daemonFunc) with AutoConf.Enabled=true and the default AutoConf.URL while repo/swarm.key is present or LIBP2P_FORCE_PNET=1 is set.","commonSituations":"Operator runs a private IPFS swarm (cluster, airgapped network) copied from a public-net config that has AutoConf left at defaults; CI sets LIBP2P_FORCE_PNET for tests without disabling AutoConf.","solutions":["Set AutoConf.Enabled=false in the config","Configure AutoConf.URL to your private swarm's configuration service endpoint","Remove swarm.key / unset LIBP2P_FORCE_PNET if the node was not meant to be private","Ensure the private config value is persisted with: ipfs config AutoConf.URL '<private-url>'"],"exampleFix":"// before\nipfs --repo-dir /pnet daemon   # swarm.key present, AutoConf default URL\n// after\nipfs config AutoConf.Enabled false\n# or\nipfs config AutoConf.URL 'https://conf.private-swarm.example'\nipfs --repo-dir /pnet daemon","handlingStrategy":"validation","validationCode":"private := swarmKeyExists() || os.Getenv(\"LIBP2P_FORCE_PNET\") != \"\"\nurl := cfg.AutoConf.URL.WithDefault(config.DefaultAutoConfURL)\nif private && url == config.DefaultAutoConfURL { cfg.AutoConf.Enabled = false }","typeGuard":null,"tryCatchPattern":"if err := config.ValidateAutoConfWithRepo(repoPath); err != nil { return fmt.Errorf(\"daemon startup blocked by AutoConf policy: %w\", err) }","preventionTips":["When deploying a private swarm, immediately set AutoConf.Enabled=false in the base config","Never combine LIBP2P_FORCE_PNET with default AutoConf settings in CI or containers","Audit config templates after copying from public-net setups"],"tags":["autoconf","private-network","swarm-key","config-validation"],"backgroundTag":"private-network-default-url","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"}