{"record":{"id":"ed17014942913fe8","repo":"ipfs/kubo","slug":"could-not-connect-to-migration-peer-q-s","errorCode":null,"errorMessage":"could not connect to migration peer %q: %s","messagePattern":"could not connect to migration peer %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/ipfs/kubo/add_migrations.go","lineNumber":118,"sourceCode":"\n// addMigrationPaths adds the files at paths to IPFS, optionally pinning\n// them. This is done after connecting to the peer.\nfunc addMigrationPaths(ctx context.Context, node *core.IpfsNode, peerInfo peer.AddrInfo, paths []path.Path, pin bool) error {\n\tif len(paths) == 0 {\n\t\treturn errors.New(\"nothing downloaded by ipfs fetcher\")\n\t}\n\tif len(peerInfo.Addrs) == 0 {\n\t\treturn errors.New(\"no local swarm address for migration node\")\n\t}\n\n\tipfs, err := coreapi.NewCoreAPI(node)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Connect to temp node\n\tif err := ipfs.Swarm().Connect(ctx, peerInfo); err != nil {\n\t\treturn fmt.Errorf(\"could not connect to migration peer %q: %s\", peerInfo.ID, err)\n\t}\n\tfmt.Printf(\"connected to migration peer %q\\n\", peerInfo)\n\n\tif pin {\n\t\tpinAPI := ipfs.Pin()\n\t\tfor _, ipfsPath := range paths {\n\t\t\terr := pinAPI.Add(ctx, ipfsPath)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfmt.Printf(\"Added and pinned migration file: %q\\n\", ipfsPath)\n\t\t}\n\t\treturn nil\n\t}\n\n\tufs := ipfs.Unixfs()\n\n\t// Add migration files","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/cmd/ipfs/kubo/add_migrations.go#L100-L136","documentation":"After building a CoreAPI for the node, addMigrationPaths connects the main node's swarm to the temporary migration peer before pulling migration files. This error wraps whatever failure ipfs.Swarm().Connect returned, identifying the peer by ID.","triggerScenarios":"ipfs.Swarm().Connect(ctx, peerInfo) fails — temp node unreachable at the given addresses, transport mismatch, or handshake failure — while running daemon-triggered repo migrations.","commonSituations":"Temp node exited before connect; NAT/firewall rules on loopback; libp2p security/transport incompatibility between the old and new binary; dial timeouts under load.","solutions":["Read the wrapped %s cause: fix the underlying dial error (wrong address, connection refused, timeout)","Confirm the temp migration node is still running and its swarm address is correct","Retry the daemon with --migrate; transient dials often succeed on a second run","Bypass the networked path entirely: run `ipfs repo migrate` / fs-repo-migrations out-of-band"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := daemonCmd.Run(); err != nil {\n    if strings.Contains(err.Error(), \"could not connect to migration peer\") {\n        // retry with --migrate after confirming temp node is alive\n    }\n}","preventionTips":["Confirm the temp migration node is running before connecting","Check firewall/loopback policies allow local libp2p dials","Retry --migrate; transient dial failures are common","Fall back to `ipfs repo migrate`"],"tags":["migrations","swarm-connect","network"],"backgroundTag":"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"}