vitessio/vitess · error

no zk server found for host %v in config %v

Error message

no zk server found for host %v in config %v

What it means

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.

Source

Thrown at go/vt/zkctl/zkconf.go:195

			// if !strings.Contains(zkServer.Hostname, ".") {
			// 	panic(fmt.Errorf("expected fully qualified hostname: %v", zkServer.Hostname))
			// }
		default:
			panic(errors.New("bad command line format for zk config"))
		}
		zkConfig.Servers = append(zkConfig.Servers, zkServer)
	}
	hostname := netutil.FullyQualifiedHostnameOrPanic()
	log.Info(fmt.Sprintf("Fully qualified machine hostname was detected as: %v", hostname))
	for _, zkServer := range zkConfig.Servers {
		if (myID > 0 && myID == zkServer.ServerId) || (myID == 0 && zkServer.Hostname == hostname) {
			zkConfig.ServerId = zkServer.ServerId
			zkConfig.ClientPort = zkServer.ClientPort
			break
		}
	}
	if zkConfig.ServerId == 0 {
		panic(fmt.Errorf("no zk server found for host %v in config %v", hostname, cmdLine))
	}
	return zkConfig
}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Ensure the hostname argument exactly matches a host listed in the zk cmdLine config (compare with `hostname -f`)
  2. Fix the zk server list so it includes this host with the correct id/ports
  3. If intended for a different host, pass that host's name instead

Example fix

// before
zkConfig := zkctl.MakeZkConfigFromString(cmdLine, "localhost") // config lists zk1.example.com
// after
host, _ := os.Hostname()
zkConfig := zkctl.MakeZkConfigFromString(cmdLine, host)
Defensive patterns

Strategy: validation

Validate before calling

if !strings.Contains(cmdLine, hostname) {
    panic(fmt.Sprintf("host %s not present in zk config: %s", hostname, cmdLine))
}
zkConfig := zkctl.MakeZkConfigFromString(cmdLine, hostname)

Type guard

func hostInZkConfig(cmdLine, hostname string) bool { return strings.Contains(cmdLine, hostname) }

Try / catch

func() (cfg *zkctl.ZkConfig) {
    defer func() {
        if r := recover(); r != nil {
            log.Errorf("zk config parse failed: %v", r)
        }
    }()
    return zkctl.MakeZkConfigFromString(cmdLine, hostname)
}()

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/30e783f784655efb. Report an issue: GitHub.