{"record":{"id":"2bca25f33a7f1b48","repo":"ipfs/kubo","slug":"servehttpgateway-manet-listen-s-failed-s","errorCode":null,"errorMessage":"serveHTTPGateway: manet.Listen(%s) failed: %s","messagePattern":"serveHTTPGateway: manet\\.Listen\\((.+?)\\) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/ipfs/kubo/daemon.go","lineNumber":1092,"sourceCode":"\tlistenerAddrs := make(map[string]bool, len(listeners))\n\tfor _, listener := range listeners {\n\t\tlistenerAddrs[string(listener.Multiaddr().Bytes())] = true\n\t}\n\n\tgatewayAddrs := cfg.Addresses.Gateway\n\tfor _, addr := range gatewayAddrs {\n\t\tgatewayMaddr, err := ma.NewMultiaddr(addr)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"serveHTTPGateway: invalid gateway address: %q (err: %s)\", addr, err)\n\t\t}\n\n\t\tif listenerAddrs[string(gatewayMaddr.Bytes())] {\n\t\t\tcontinue\n\t\t}\n\n\t\tgwLis, err := manet.Listen(gatewayMaddr)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"serveHTTPGateway: manet.Listen(%s) failed: %s\", gatewayMaddr, err)\n\t\t}\n\t\tlistenerAddrs[string(gatewayMaddr.Bytes())] = true\n\t\tlisteners = append(listeners, gwLis)\n\t}\n\n\t// we might have listened to /tcp/0 - let's see what we are listing on\n\tfor _, listener := range listeners {\n\t\tfmt.Printf(\"Gateway server listening on %s\\n\", listener.Multiaddr())\n\t}\n\n\tif cfg.Gateway.ExposeRoutingAPI.WithDefault(config.DefaultExposeRoutingAPI) {\n\t\tfor _, listener := range listeners {\n\t\t\tfmt.Printf(\"Routing V1 API exposed at http://%s/routing/v1\\n\", listener.Addr())\n\t\t}\n\t}\n\n\tcmdctx := *cctx\n\tcmdctx.Gateway = true","sourceCodeStart":1074,"sourceCodeEnd":1110,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/cmd/ipfs/kubo/daemon.go#L1074-L1110","documentation":"For gateway addresses not already provided by socket activation, kubo binds the listener with manet.Listen. This error is thrown when binding fails; the message includes the multiaddr and the underlying OS/network error (address in use, permission denied, etc.).","triggerScenarios":"manet.Listen(gatewayMaddr) fails: port already bound by another process or a running daemon, binding privileged port <1024 without privileges, invalid/unavailable interface, IPv6 not available.","commonSituations":"Second ipfs daemon started while one is running on 8080; another web server (nginx, Docker proxy) owns the port; `ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/80` on Linux without CAP_NET_BIND_SERVICE.","solutions":["Check what holds the port: `ss -ltnp | grep 8080` (or lsof) and stop it, or pick a free port: `ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/18080`.","Kill stale daemons from previous runs: pkill -f \"ipfs daemon\".","For ports <1024, use IPFW/iptables redirect, setcap on the binary, or systemd socket activation instead of running as root.","Ensure the interface address exists (e.g., do not bind a specific external IP that is not assigned)."],"exampleFix":"// before: bind fails\n$ ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/80\n// after: unprivileged port + redirect or socket activation\n$ ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080","handlingStrategy":"validation","validationCode":"port=$(ipfs config Addresses.Gateway | grep -o '/tcp/[0-9]*' | cut -d/ -f3)\nif ss -ltn \"sport = :${port}\" | grep -q LISTEN; then\n  echo \"port $port already in use\"; exit 1\nfi","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"manet.Listen\") {\n    log.Fatalf(\"gateway port unavailable; free the port or change Addresses.Gateway: %v\", err)\n}","preventionTips":["Pre-check the port with ss/lsof before starting the daemon.","Run only one daemon per IPFS_PATH (and per port set).","Use unprivileged ports (>1024); use socket activation for privileged ports.","In containers, publish/avoid collisions on 8080 explicitly."],"tags":["network","bind","port-in-use","gateway"],"backgroundTag":"address-already-in-use","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"}