{"record":{"id":"18b0ca8b4d7226f2","repo":"ipfs/kubo","slug":"servehttpgateway-manet-tonetaddr-failed-w","errorCode":null,"errorMessage":"serveHTTPGateway: manet.ToNetAddr() failed: %w","messagePattern":"serveHTTPGateway: manet\\.ToNetAddr\\(\\) failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/ipfs/kubo/daemon.go","lineNumber":1166,"sourceCode":"\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}\n\n\t\t// Wait for all listeners to be ready or any to fail\n\t\tfor _, ready := range readyChannels {\n\t\t\tselect {\n\t\t\tcase <-ready:\n\t\t\t\t// This listener is ready\n\t\t\tcase err := <-errc:\n\t\t\t\treturn nil, fmt.Errorf(\"serveHTTPGateway: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\taddr, err := manet.ToNetAddr(rewriteMaddrToUseLocalhostIfItsAny(listeners[0].Multiaddr()))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"serveHTTPGateway: manet.ToNetAddr() failed: %w\", err)\n\t\t}\n\t\tif err := node.Repo.SetGatewayAddr(addr); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"serveHTTPGateway: SetGatewayAddr() failed: %w\", err)\n\t\t}\n\t}\n\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(errc)\n\t}()\n\n\treturn errc, nil\n}\n\nconst gatewayProtocolID protocol.ID = \"/ipfs/gateway\" // FIXME: specify https://github.com/ipfs/specs/issues/433\n\nfunc serveTrustlessGatewayOverLibp2p(cctx *oldcmds.Context) (<-chan error, error) {\n\tnode, err := cctx.ConstructNode()","sourceCodeStart":1148,"sourceCodeEnd":1184,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/cmd/ipfs/kubo/daemon.go#L1148-L1184","documentation":"After listeners are ready, kubo converts the first gateway listener's multiaddr to a TCP/UDP net address via manet.ToNetAddr to advertise it. This error is thrown if that conversion fails, which normally indicates the listener's multiaddr is not a network-translatable form (unexpected transport).","triggerScenarios":"manet.ToNetAddr() fails on rewriteMaddrToUseLocalhostIfItsAny(listeners[0].Multiaddr()): the configured gateway multiaddr is a form manet cannot map to a net.Addr (e.g., unix-socket or other non-IP multiaddr in Addresses.Gateway).","commonSituations":"Configuring Addresses.Gateway with a /unix/ or other exotic multiaddr; custom transports in config that the gateway HTTP server does not support; config edited by tooling expecting only /ip4|/ip6 tcp forms.","solutions":["Set Addresses.Gateway to a standard TCP multiaddr: `ipfs config Addresses.Gateway /ip4/127.0.0.1/tcp/8080`.","Inspect `ipfs config Addresses.Gateway` and remove any /unix/ or non-IP entries.","If you need multiple gateways, list only /ip4|/ip6 + /tcp entries in the array.","Re-run after fixing; conversion always succeeds for plain IP+TCP multiaddrs."],"exampleFix":"// before\n$ ipfs config Addresses.Gateway /unix/tmp/gw.sock\n// after\n$ ipfs config Addresses.Gateway /ip4/127.0.0.1/tcp/8080","handlingStrategy":"validation","validationCode":"gw, _ := ipfsConfig.Get(\"Addresses.Gateway\")\nfor _, a := range gw.([]string) {\n    if !strings.HasPrefix(a, \"/ip4/\") && !strings.HasPrefix(a, \"/ip6/\") {\n        return fmt.Errorf(\"gateway addr %q must be an IP+TCP multiaddr\", a)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"manet.ToNetAddr() failed\") {\n    log.Fatalf(\"unsupported gateway multiaddr; use /ip4|/ip6 + /tcp form: %v\", err)\n}","preventionTips":["Restrict Addresses.Gateway to /ip4 or /ip6 + /tcp multiaddrs.","Avoid /unix/ and custom transport multiaddrs for the gateway.","Validate the config array after automated edits.","Keep gateway and swarm addresses in separate config keys."],"tags":["multiaddr","gateway","config"],"backgroundTag":"invalid-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"}