{"record":{"id":"f9c3204d314609fd","repo":"louislam/uptime-kuma","slug":"time-offset-offset-tofixed-3-ms-exceeds-thresho","errorCode":null,"errorMessage":"Time offset ${offset.toFixed(3)}ms exceeds threshold ${offsetThreshold}ms","messagePattern":"Time offset (.+?)ms exceeds threshold (.+?)ms","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"server/monitor-types/ntp.js","lineNumber":46,"sourceCode":"\n        heartbeat.ping = dayjs().valueOf() - startTime;\n\n        const { stratum, offset, rootDispersion, refid, roundTripDelay } = ntpResult;\n\n        heartbeat.msg = `Stratum: ${stratum}, RefID: ${refid}, Offset: ${offset.toFixed(3)}ms, Delay: ${roundTripDelay.toFixed(3)}ms, Dispersion: ${rootDispersion.toFixed(3)}ms`;\n\n        if (stratum === 16) {\n            throw new Error(\"NTP server is unsynchronized (stratum 16)\");\n        }\n\n        const stratumThreshold = monitor.ntp_stratum_threshold || 5;\n        if (stratum >= stratumThreshold) {\n            throw new Error(`Stratum ${stratum} meets or exceeds threshold ${stratumThreshold}`);\n        }\n\n        const offsetThreshold = monitor.ntp_time_offset_threshold || 1000;\n        if (Math.abs(offset) >= offsetThreshold) {\n            throw new Error(`Time offset ${offset.toFixed(3)}ms exceeds threshold ${offsetThreshold}ms`);\n        }\n\n        const dispersionThreshold = monitor.ntp_root_dispersion_threshold || 500;\n        if (rootDispersion >= dispersionThreshold) {\n            throw new Error(\n                `Root dispersion ${rootDispersion.toFixed(3)}ms exceeds threshold ${dispersionThreshold}ms`\n            );\n        }\n\n        heartbeat.status = UP;\n    }\n\n    /**\n     * Query an NTP server via UDP\n     * @param {string} hostname NTP server hostname or IP\n     * @param {number} port NTP server port (usually 123)\n     * @param {number} timeout Timeout in milliseconds\n     * @returns {Promise<object>} Parsed NTP response data","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/monitor-types/ntp.js#L28-L64","documentation":"Thrown when abs(offset) >= monitor.ntp_time_offset_threshold (default 1000 ms). 'offset' is the client-server clock offset computed per RFC 5905: ((T2-T1)+(T3-T4))/2. A large absolute offset means the Uptime Kuma host's clock and the target NTP server disagree beyond the allowed tolerance.","triggerScenarios":"queryNTP succeeds, |offset| >= offsetThreshold. Caused by the monitoring host's clock drifting (common on VMs/containers without working time sync), large asymmetric network delay, or the target itself serving skewed time.","commonSituations":"Container/VM host without ntpd/chronyd, so it drifts; high-latency or jittery WAN to the NTP server; monitoring a stratum-1 across an intercontinental link; host clock stepped by kvmclock/PTP incorrectly.","solutions":["Enable time sync on the Uptime Kuma host (install chrony/ntp, or enable the hypervisor's time integration).","Point the monitor at a geographically closer NTP server to cut asymmetric delay.","If the skew is expected/benign, raise monitor.ntp_time_offset_threshold.","Run 'chronyc tracking' / 'ntpq -p' on the monitoring host to confirm its own offset is small."],"exampleFix":"// before: monitor.ntp_time_offset_threshold = 1000  (cross-region link)\n// after:  monitor.ntp_time_offset_threshold = 5000\n// and on the kuma host: sudo apt-get install -y chrony && sudo systemctl enable --now chrony","handlingStrategy":"validation","validationCode":"function validateOffsetThreshold(monitor) {\n  const t = Number(monitor.ntp_time_offset_threshold ?? 1000);\n  if (!Number.isFinite(t) || t <= 0) throw new Error('ntp_time_offset_threshold must be > 0');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run chrony/ntpd on the Uptime Kuma host so its clock doesn't drift.","Set ntp_time_offset_threshold based on measured baseline offset to the target.","Prefer a geographically close NTP server to reduce asymmetric delay."],"tags":["ntp","clock-skew","threshold","uptime-kuma"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}