{"record":{"id":"bddf6180e6e2136b","repo":"prometheus/node_exporter","slug":"only-ip-address-of-local-ntp-server-is-valid-for","errorCode":null,"errorMessage":"only IP address of local NTP server is valid for --collector.ntp.server","messagePattern":"only IP address of local NTP server is valid for --collector\\.ntp\\.server","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/ntp.go","lineNumber":66,"sourceCode":")\n\ntype ntpCollector struct {\n\tstratum, leap, rtt, offset, reftime, rootDelay, rootDispersion, sanity typedDesc\n\tlogger                                                                 *slog.Logger\n}\n\nfunc init() {\n\tregisterCollector(\"ntp\", defaultDisabled, NewNtpCollector)\n}\n\n// NewNtpCollector returns a new Collector exposing sanity of local NTP server.\n// Default definition of \"local\" is:\n// - collector.ntp.server address is a loopback address (or collector.ntp.server-is-mine flag is turned on)\n// - the server is reachable with outgoing IP_TTL = 1\nfunc NewNtpCollector(logger *slog.Logger) (Collector, error) {\n\tipaddr := net.ParseIP(*ntpServer)\n\tif !*ntpServerIsLocal && (ipaddr == nil || !ipaddr.IsLoopback()) {\n\t\treturn nil, fmt.Errorf(\"only IP address of local NTP server is valid for --collector.ntp.server\")\n\t}\n\n\tif *ntpProtocolVersion < 2 || *ntpProtocolVersion > 4 {\n\t\treturn nil, fmt.Errorf(\"invalid NTP protocol version %d; must be 2, 3, or 4\", *ntpProtocolVersion)\n\t}\n\n\tif *ntpOffsetTolerance < 0 {\n\t\treturn nil, fmt.Errorf(\"offset tolerance must be non-negative\")\n\t}\n\n\tif *ntpServerPort < 1 || *ntpServerPort > 65535 {\n\t\treturn nil, fmt.Errorf(\"invalid NTP port number %d; must be between 1 and 65535 inclusive\", *ntpServerPort)\n\t}\n\n\tlogger.Warn(\"This collector is deprecated and will be removed in the next major version release.\")\n\treturn &ntpCollector{\n\t\tstratum: typedDesc{prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, ntpSubsystem, \"stratum\"),","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/ntp.go#L48-L84","documentation":"NewNtpCollector validates the --collector.ntp.server flag before creating the collector. Unless --collector.ntp.server-is-mine is set, the value must parse as an IP address (net.ParseIP non-nil) and be a loopback address. Hostnames, non-loopback IPs, or arbitrary strings are rejected with this error at startup.","triggerScenarios":"Starting node_exporter with --collector.ntp.server set to a hostname (e.g. pool.ntp.org), an empty value, a non-IP string, or a public/non-loopback IP, while --collector.ntp.server-is-mine is false.","commonSituations":"Users copying examples that use NTP pool hostnames; pointing the collector at a remote public NTP server instead of a local one (the collector intentionally requires a local server because it uses IP TTL=1 probes); forgetting that the flag takes an IP, not a DNS name.","solutions":["Resolve your local NTP server's address and pass it as an IP literal, e.g. --collector.ntp.server=127.0.0.1.","Only if you truly control the server and accept the TTL=1 reachability model, add --collector.ntp.server-is-mine to bypass the loopback check.","Do not use hostnames or public NTP pools (pool.ntp.org); this collector is not designed for them.","If you need generic NTP monitoring, use a different exporter (e.g. an NTP exporter based on beevik/ntp) since this collector is deprecated."],"exampleFix":"// before\n//   --collector.ntp.server=pool.ntp.org\n// after: local server IP, or explicitly claim the server\n//   --collector.ntp.server=192.168.1.1\n//   --collector.ntp.server-is-mine","handlingStrategy":"validation","validationCode":"// shell: validate the flag value before starting the exporter\nSRV=\"$(grep -Po '(?<=--collector\\.ntp\\.server=)\\S+' <<<'...')\"\nipcalc \"$SRV\" >/dev/null 2>&1 || echo \"$SRV is not an IP literal\"\npython3 -c \"import ipaddress,sys; a=ipaddress.ip_address('$SRV'); sys.exit(0 if a.is_loopback else 1)\" || echo \"$SRV is not loopback\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat --collector.ntp.server as an IP literal only; never pass hostnames.","Resolve your local NTP server to an IP in config management before templating the flag.","Use --collector.ntp.server-is-mine only when you control the target server.","Remember the collector is deprecated; prefer alternative NTP exporters for non-local servers."],"tags":["ntp","configuration","cli-flag","validation"],"backgroundTag":"invalid-flag-value","analyzedSha":"17ddd77c59ba27e1508e9f7894b1e55b44d6aed3","analyzedAt":"2026-09-07T17:54:06.211Z","contentChangedAt":"2026-09-07T17:54:06.211Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}