{"record":{"id":"20fc0fe906b3f767","repo":"ipfs/kubo","slug":"servehttpgateway-getconfig-failed-s","errorCode":null,"errorMessage":"serveHTTPGateway: GetConfig() failed: %s","messagePattern":"serveHTTPGateway: GetConfig\\(\\) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cmd/ipfs/kubo/daemon.go","lineNumber":1066,"sourceCode":"\n\t// Print listeners\n\tfor _, host := range hosts {\n\t\tprotocolsSet := addrMap[host]\n\t\tprotocols := make([]string, 0, len(protocolsSet))\n\t\tfor protocol := range protocolsSet {\n\t\t\tprotocols = append(protocols, protocol)\n\t\t}\n\t\tsort.Strings(protocols)\n\t\tfmt.Printf(\"Swarm listening on %s (%s)\\n\", host, strings.Join(protocols, \"+\"))\n\t}\n\tfmt.Printf(\"Run 'ipfs id' to inspect announced and discovered multiaddrs of this node.\\n\")\n}\n\n// serveHTTPGateway collects options, creates listener, prints status message and starts serving requests.\nfunc serveHTTPGateway(req *cmds.Request, cctx *oldcmds.Context) (<-chan error, error) {\n\tcfg, err := cctx.GetConfig()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"serveHTTPGateway: GetConfig() failed: %s\", err)\n\t}\n\n\tlisteners, err := sockets.TakeListeners(\"io.ipfs.gateway\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"serveHTTPGateway: socket activation failed: %s\", err)\n\t}\n\n\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}","sourceCodeStart":1048,"sourceCodeEnd":1084,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/cmd/ipfs/kubo/daemon.go#L1048-L1084","documentation":"serveHTTPGateway wraps any failure from cctx.GetConfig() (which loads the node's $IPFS_PATH/config file) with this message during gateway startup. The gateway cannot determine Addresses.Gateway or Gateway options without the config, so daemon startup aborts. The wrapped inner error contains the actual reason (unreadable file, invalid JSON, repo not initialized).","triggerScenarios":"ipfs daemon startup when cctx.GetConfig() returns an error: config file missing, unreadable permissions, malformed JSON, or repo not initialized.","commonSituations":"Running the daemon before `ipfs init`; corrupted or hand-edited config JSON; wrong IPFS_PATH pointing to a non-repo directory; permission changes after running as a different user (root vs. user).","solutions":["Run `ipfs init` if the repo does not exist (check IPFS_PATH).","Validate the config: `ipfs config show` or `jq . $IPFS_PATH/config` to find JSON syntax errors and fix them.","Fix file permissions on $IPFS_PATH/config so the daemon user can read it.","Verify IPFS_PATH points to the intended repo, not an empty or wrong directory."],"exampleFix":"// before: daemon fails\n$ IPFS_PATH=/nonexistent ipfs daemon\nserveHTTPGateway: GetConfig() failed: ... no such file or directory\n// after\n$ ipfs init\n$ ipfs daemon","handlingStrategy":"validation","validationCode":"if [ ! -f \"$IPFS_PATH/config\" ]; then ipfs init; fi\njq empty \"$IPFS_PATH/config\" || { echo 'config JSON invalid'; exit 1; }","typeGuard":null,"tryCatchPattern":"err := daemon.Serve(ctx)\nif err != nil && strings.Contains(err.Error(), \"GetConfig() failed\") {\n    log.Fatalf(\"fix $IPFS_PATH/config and re-init: %v\", err)\n}","preventionTips":["Always `ipfs init` before first `ipfs daemon`.","Validate config JSON after manual edits (jq empty).","Keep a backup of a known-good config.","Pin IPFS_PATH per environment so the daemon never reads the wrong repo."],"tags":["config","daemon","gateway","startup"],"backgroundTag":"config-load-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"}