{"record":{"id":"aa7b37d48f6baff0","repo":"ipfs/kubo","slug":"ambiguous-multiaddr-s-could-refer-to-s-or-s","errorCode":null,"errorMessage":"ambiguous multiaddr %s could refer to %s or %s","messagePattern":"ambiguous multiaddr (.+?) could refer to (.+?) or (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/p2p.go","lineNumber":246,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(addrs) == 0 {\n\t\treturn nil, errors.New(\"fail to resolve the multiaddr:\" + multiaddr.String())\n\t}\n\tvar info peer.AddrInfo\n\tfor _, addr := range addrs {\n\t\ttaddr, id := peer.SplitAddr(addr)\n\t\tif id == \"\" {\n\t\t\t// not an ipfs addr, skipping.\n\t\t\tcontinue\n\t\t}\n\t\tswitch info.ID {\n\t\tcase \"\":\n\t\t\tinfo.ID = id\n\t\tcase id:\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"ambiguous multiaddr %s could refer to %s or %s\",\n\t\t\t\tmultiaddr,\n\t\t\t\tinfo.ID,\n\t\t\t\tid,\n\t\t\t)\n\t\t}\n\t\tinfo.Addrs = append(info.Addrs, taddr)\n\t}\n\treturn &info, nil\n}\n\nvar p2pListenCmd = &cmds.Command{\n\tStatus: cmds.Experimental,\n\tHelptext: cmds.HelpText{\n\t\tTagline: \"Create libp2p service.\",\n\t\tShortDescription: `\nCreate a libp2p protocol handler that forwards incoming connections to\n<target-address>.","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/p2p.go#L228-L264","documentation":"After resolving a target multiaddr, parseIpfsAddr splits each resolved address into transport address and peer ID. If different resolved addresses carry different peer IDs, the original multiaddr is ambiguous - it could refer to two distinct peers - so kubo refuses to pick one and returns this error naming both IDs.","triggerScenarios":"Calling an `ipfs p2p` command with a target like a dnsaddr or round-robin DNS name whose resolved addresses embed two different /p2p/<peerid> values.","commonSituations":"A dnsaddr TXT record listing multiple different peers; a load-balanced hostname mixing peers; stale/mixed DNS records after rekeying a node; copy-pasting a multiaddr that concatenates addresses of two nodes.","solutions":["Use one explicit target per peer: pass `/ip4/x.x.x.x/tcp/4001/p2p/<peerid>` with the specific peer ID you want.","Fix the dnsaddr/DNS records so all resolved addresses carry the same peer ID.","If multiple peers are intentional, issue one p2p forward per peer instead of one ambiguous multiaddr."],"exampleFix":"// before\nipfs p2p forward /p2p/x/1.0.0 :8080 /dnsaddr/mixed.example.com   # resolves to two peer IDs\n// after\nipfs p2p forward /p2p/x/1.0.0 :8080 /ip4/203.0.113.5/tcp/4001/p2p/12D3KooW...","handlingStrategy":"validation","validationCode":"// resolve first, then verify a single peer ID across results\nresolved, _ := madns.Resolve(ctx, ma)\nids := map[string]struct{}{}\nfor _, a := range resolved {\n    if _, id := peer.SplitAddr(a); id != \"\" {\n        ids[id.String()] = struct{}{}\n    }\n}\nif len(ids) > 1 {\n    return errors.New(\"ambiguous target: multiple peer IDs\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep one peer per dnsaddr hostname; use separate hostnames per peer.","Pass explicit /p2p/<peerid> multiaddrs in automation instead of shared DNS names.","After rekeying a node, update DNS records so old and new IDs never coexist under one name."],"tags":["network","dns","multiaddr"],"backgroundTag":"ambiguous-multiaddr","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"}