{"record":{"id":"cf4dbdb25e6075ee","repo":"ipfs/kubo","slug":"servehttpgateway-setgatewayaddr-failed-w","errorCode":null,"errorMessage":"serveHTTPGateway: SetGatewayAddr() failed: %w","messagePattern":"serveHTTPGateway: SetGatewayAddr\\(\\) failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/ipfs/kubo/daemon.go","lineNumber":1169,"sourceCode":"\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()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"serveHTTPGatewayOverLibp2p: ConstructNode() failed: %s\", err)\n\t}","sourceCodeStart":1151,"sourceCodeEnd":1187,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/cmd/ipfs/kubo/daemon.go#L1151-L1187","documentation":"To make `ipfs daemon` discoverable, kubo persists the resolved gateway address into the repo via node.Repo.SetGatewayAddr(addr). This error wraps a failure writing that address (repo/datastore write error), causing gateway startup to abort even though the listener is already bound.","triggerScenarios":"node.Repo.SetGatewayAddr(addr) errors: repo closed or in read-only mode, datastore write failure, disk full, permission denied on the repo directory, or repo shutdown racing startup.","commonSituations":"Read-only mounts of $IPFS_PATH (containers, snapshots); disk full; repo owned by another user; FUSE/sync filesystems rejecting writes.","solutions":["Ensure $IPFS_PATH is writable by the daemon user (check ownership and mount ro/rw).","Free disk space if the datastore reports ENOSPC in the wrapped error.","Avoid bind-mounting the repo read-only in containers; mount rw or point IPFS_PATH at a writable volume.","Re-run `ipfs repo fsck` if a prior crash left the repo in a bad state."],"exampleFix":"// before: repo read-only in container\n-v /snapshots/ipfs:/data/ipfs:ro\n// after\n-v ipfs-data:/data/ipfs:rw","handlingStrategy":"validation","validationCode":"f, err := os.OpenFile(filepath.Join(ipfsPath, \"config\"), os.O_WRONLY, 0)\nif err != nil {\n    return fmt.Errorf(\"repo not writable by daemon user: %w\", err)\n}\nf.Close()","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"SetGatewayAddr() failed\") {\n    log.Fatalf(\"check $IPFS_PATH writability/disk space: %v\", err)\n}","preventionTips":["Mount the repo volume read-write; never ro in containers.","Ensure the daemon user owns $IPFS_PATH.","Alert on disk-full conditions for the repo volume.","Run `ipfs repo fsck` after crashes."],"tags":["repo","datastore","write","gateway"],"backgroundTag":"repo-write-failed","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"}