{"record":{"id":"9fe53652b976ce88","repo":"prometheus/node_exporter","slug":"invalid-ntp-port-number-d-must-be-between-1-and","errorCode":null,"errorMessage":"invalid NTP port number %d; must be between 1 and 65535 inclusive","messagePattern":"invalid NTP port number (.+?); must be between 1 and 65535 inclusive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/ntp.go","lineNumber":78,"sourceCode":"// 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\"),\n\t\t\t\"NTPD stratum.\",\n\t\t\tnil, nil,\n\t\t), prometheus.GaugeValue},\n\t\tleap: typedDesc{prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, ntpSubsystem, \"leap\"),\n\t\t\t\"NTPD leap second indicator, 2 bits.\",\n\t\t\tnil, nil,\n\t\t), prometheus.GaugeValue},\n\t\trtt: typedDesc{prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, ntpSubsystem, \"rtt_seconds\"),\n\t\t\t\"RTT to NTPD.\",\n\t\t\tnil, nil,","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/ntp.go#L60-L96","documentation":"NewNtpCollector validates --collector.ntp.server-port and accepts only values from 1 to 65535 inclusive. Ports outside this range cannot be valid UDP ports, so the constructor returns this formatted error at startup.","triggerScenarios":"Starting node_exporter with --collector.ntp.server-port=0, a negative number, or a value above 65535 (e.g. 65536); the int flag parses successfully but fails semantic validation here.","commonSituations":"Setting port 0 intending 'default NTP port' (use 123 instead); mixing up decimal/hex or appending stray digits; config templating that substitutes an empty or invalid default that becomes 0.","solutions":["Use the standard NTP port: --collector.ntp.server-port=123.","If a custom local server runs on another port, pick an integer in [1,65535].","Correct any template/default that renders 0 or >65535 for this flag.","Note the collector also logs a deprecation warning; consider migrating to an alternative NTP exporter."],"exampleFix":"// before\n//   --collector.ntp.server-port=0\n// after\n//   --collector.ntp.server-port=123","handlingStrategy":"validation","validationCode":"# shell: validate UDP port range before launch\n[ \"$NTP_PORT\" -ge 1 ] && [ \"$NTP_PORT\" -le 65535 ] || { echo \"invalid --collector.ntp.server-port: $NTP_PORT\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use port 123 (standard NTP) unless the local server deliberately listens elsewhere.","Never use 0 intending 'default'; it is rejected.","Validate port fields in config templates against 1-65535.","Watch for deprecation warnings and plan migration away from this collector."],"tags":["ntp","configuration","cli-flag","validation","port"],"backgroundTag":"value-out-of-range","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"}