{"record":{"id":"1578c21cad495040","repo":"cloudflare/cloudflared","slug":"errmultiplemetricsserverfound","errorCode":"ErrMultipleMetricsServerFound","errorMessage":"multiple metrics server found","messagePattern":"multiple metrics server found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"diagnostic/error.go","lineNumber":25,"sourceCode":"var (\n\t// Error used when there is no log directory available.\n\tErrManagedLogNotFound = errors.New(\"managed log directory not found\")\n\t// Error used when it is not possible to collect logs using the log configuration.\n\tErrLogConfigurationIsInvalid = errors.New(\"provided log configuration is invalid\")\n\t// Error used when parsing the fields of the output of collector.\n\tErrInsufficientLines = errors.New(\"insufficient lines\")\n\t// Error used when parsing the lines of the output of collector.\n\tErrInsuficientFields = errors.New(\"insufficient fields\")\n\t// Error used when given key is not found while parsing KV.\n\tErrKeyNotFound = errors.New(\"key not found\")\n\t// Error used when there is no disk volume information available.\n\tErrNoVolumeFound = errors.New(\"no disk volume information found\")\n\t// Error user when the base url of the diagnostic client is not provided.\n\tErrNoBaseURL = errors.New(\"no base url\")\n\t// Error used when no metrics server is found listening to the known addresses list (check [metrics.GetMetricsKnownAddresses]).\n\tErrMetricsServerNotFound = errors.New(\"metrics server not found\")\n\t// Error used when multiple metrics server are found listening to the known addresses list (check [metrics.GetMetricsKnownAddresses]).\n\tErrMultipleMetricsServerFound = errors.New(\"multiple metrics server found\")\n\t// Error used when a temporary file creation fails within the diagnostic procedure\n\tErrCreatingTemporaryFile = errors.New(\"temporary file creation failed\")\n)\n","sourceCodeStart":7,"sourceCodeEnd":29,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/diagnostic/error.go#L7-L29","documentation":"ErrMultipleMetricsServerFound is returned by FindMetricsServer when more than one cloudflared metrics server responds on the known addresses, making it ambiguous which instance a diagnostic should target. RunDiagnostic surfaces it, and the CLI subcommand handles it by listing all discovered instances (subcommands.go:1132).","triggerScenarios":"Running a diagnostic command while two or more cloudflared processes are running with metrics servers on known addresses; FindMetricsServer returns the instances plus ErrMultipleMetricsServerFound at diagnostic/diagnostic_utils.go:140.","commonSituations":"Multiple concurrent tunnel runs (dev + service instance), leftover orphaned cloudflared processes, or running several replicas on one host each listening on a known metrics port.","solutions":["Stop extra cloudflared instances so exactly one metrics server is running, then retry.","List the reported instances (the CLI logs them) and target the intended one explicitly via its metrics address.","Assign distinct --metrics addresses/ports per instance and query the specific one you need.","Handle errors.Is(err, diagnostic.ErrMultipleMetricsServerFound) by surfacing the instance list instead of failing."],"exampleFix":"if errors.Is(err, diagnostic.ErrMultipleMetricsServerFound) {\n\tfor _, s := range instances {\n\t\tlog.Info().Msgf(\"instance: %s\", s)\n\t}\n\treturn nil\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"states, instances, err := diagnostic.FindMetricsServer(ctx, log)\nif errors.Is(err, diagnostic.ErrMultipleMetricsServerFound) {\n\tlog.Info().Msgf(\"Found multiple instances running:\")\n\t// enumerate instances and pick or ask\n}","preventionTips":["Run at most one cloudflared instance per host, or give each a distinct --metrics address.","Clean up orphaned cloudflared processes before running diagnostics.","Target a specific instance's metrics address instead of auto-discovery when multiple instances are expected."],"tags":["metrics","ambiguity","diagnostic","multi-instance"],"backgroundTag":"multiple-matches-found","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}