{"record":{"id":"30e783f784655efb","repo":"vitessio/vitess","slug":"no-zk-server-found-for-host-v-in-config-v","errorCode":null,"errorMessage":"no zk server found for host %v in config %v","messagePattern":"no zk server found for host (.+?) in config (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/zkctl/zkconf.go","lineNumber":195,"sourceCode":"\t\t\t// if !strings.Contains(zkServer.Hostname, \".\") {\n\t\t\t// \tpanic(fmt.Errorf(\"expected fully qualified hostname: %v\", zkServer.Hostname))\n\t\t\t// }\n\t\tdefault:\n\t\t\tpanic(errors.New(\"bad command line format for zk config\"))\n\t\t}\n\t\tzkConfig.Servers = append(zkConfig.Servers, zkServer)\n\t}\n\thostname := netutil.FullyQualifiedHostnameOrPanic()\n\tlog.Info(fmt.Sprintf(\"Fully qualified machine hostname was detected as: %v\", hostname))\n\tfor _, zkServer := range zkConfig.Servers {\n\t\tif (myID > 0 && myID == zkServer.ServerId) || (myID == 0 && zkServer.Hostname == hostname) {\n\t\t\tzkConfig.ServerId = zkServer.ServerId\n\t\t\tzkConfig.ClientPort = zkServer.ClientPort\n\t\t\tbreak\n\t\t}\n\t}\n\tif zkConfig.ServerId == 0 {\n\t\tpanic(fmt.Errorf(\"no zk server found for host %v in config %v\", hostname, cmdLine))\n\t}\n\treturn zkConfig\n}\n","sourceCodeStart":177,"sourceCodeEnd":199,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/zkctl/zkconf.go#L177-L199","documentation":"MakeZkConfigFromString parses a zkctl command-line config and finds the server entry whose hostname matches; if none matches, zkConfig.ServerId stays 0 and this code panics. It indicates the requested host is not present in the provided zk config string.","triggerScenarios":"Calling zkctl.MakeZkConfigFromString(cmdLine, hostname) where hostname does not appear among the server entries in the config string — e.g. wrong hostname resolution (localhost vs FQDN) or the config lists other hosts.","commonSituations":"Hostname mismatch (short name vs fully-qualified), starting a local zk on a host absent from the vitess zk config, typos in the zk server list passed on the command line.","solutions":["Ensure the hostname argument exactly matches a host listed in the zk cmdLine config (compare with `hostname -f`)","Fix the zk server list so it includes this host with the correct id/ports","If intended for a different host, pass that host's name instead"],"exampleFix":"// before\nzkConfig := zkctl.MakeZkConfigFromString(cmdLine, \"localhost\") // config lists zk1.example.com\n// after\nhost, _ := os.Hostname()\nzkConfig := zkctl.MakeZkConfigFromString(cmdLine, host)","handlingStrategy":"validation","validationCode":"if !strings.Contains(cmdLine, hostname) {\n    panic(fmt.Sprintf(\"host %s not present in zk config: %s\", hostname, cmdLine))\n}\nzkConfig := zkctl.MakeZkConfigFromString(cmdLine, hostname)","typeGuard":"func hostInZkConfig(cmdLine, hostname string) bool { return strings.Contains(cmdLine, hostname) }","tryCatchPattern":"func() (cfg *zkctl.ZkConfig) {\n    defer func() {\n        if r := recover(); r != nil {\n            log.Errorf(\"zk config parse failed: %v\", r)\n        }\n    }()\n    return zkctl.MakeZkConfigFromString(cmdLine, hostname)\n}()","preventionTips":["Use the fully-qualified hostname from os.Hostname()/hostname -f","Keep the zk server list and hostnames in one source of truth","Pre-validate the host appears in the config string before parsing"],"tags":["zookeeper","zkctl","config","panic"],"backgroundTag":"host-missing-in-zk-config","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}