HangfireIO/Hangfire · error · ArgumentOutOfRangeException

CheckInterval must be either non-negative and equal to or le

Error message

CheckInterval must be either non-negative and equal to or less than {ServerWatchdog.MaxServerCheckInterval.Hours} hours

What it means

Thrown as ArgumentOutOfRangeException by the obsolete ServerWatchdogOptions.CheckInterval setter when the supplied TimeSpan is negative or exceeds ServerWatchdog.MaxServerCheckInterval (24 hours). CheckInterval governs how often the watchdog scans for timed-out servers; an out-of-range value would either overload storage (too small) or leave dead servers undetected (too large), so the setter rejects it at line 55.

Source

Thrown at src/Hangfire.Core/Obsolete/ServerWatchdogOptions.cs:55

            set
            {
                if (value < TimeSpan.Zero || value > ServerWatchdog.MaxServerTimeout)
                {
                    throw new ArgumentOutOfRangeException(nameof(value), $"ServerTimeout must be either non-negative and equal to or less than {ServerWatchdog.MaxServerTimeout.Hours} hours");
                }

                _serverTimeout = value;
            }
        }

        public TimeSpan CheckInterval
        {
            get { return _checkInterval; }
            set
            {
                if (value < TimeSpan.Zero || value > ServerWatchdog.MaxServerCheckInterval)
                {
                    throw new ArgumentOutOfRangeException(nameof(value), $"CheckInterval must be either non-negative and equal to or less than {ServerWatchdog.MaxServerCheckInterval.Hours} hours");

                };
                _checkInterval = value;
            }
        }
    }
}

View on GitHub (pinned to c236dd0f93)

Solutions

  1. Use the non-obsolete BackgroundJobServerOptions.ServerCheckInterval instead, which enforces the same 0..24h bounds and is supported.
  2. Validate/clamp the configured TimeSpan to [TimeSpan.Zero, TimeSpan.FromHours(24)] before assignment.
  3. Parse configuration values with explicit units (TimeSpan.Parse / TimeSpan.FromMinutes) and log them to catch magnitude errors.

Example fix

// before
watchdog.CheckInterval = TimeSpan.FromHours(48); // throws

// after
var interval = TimeSpan.FromSeconds(cfg.IntervalSeconds);
serverOptions.ServerCheckInterval = interval > ServerWatchdog.MaxServerCheckInterval
    ? ServerWatchdog.MaxServerCheckInterval : interval;
Defensive patterns

Strategy: validation

Validate before calling

var interval = TimeSpan.FromSeconds(cfg.IntervalSeconds);
if (interval < TimeSpan.Zero || interval > ServerWatchdog.MaxServerCheckInterval)
    throw new ArgumentOutOfRangeException(nameof(interval));
options.CheckInterval = interval;

Prevention

When it happens

Trigger: Setting options.CheckInterval to a value where value < TimeSpan.Zero or value > TimeSpan.FromHours(24). E.g. options.CheckInterval = TimeSpan.FromHours(30), or a negative TimeSpan.

Common situations: A configuration value parsed with the wrong time unit (minutes interpreted as hours) yielding >24h; a negative TimeSpan from miscomputed offsets; reusing a ServerTimeout value for CheckInterval where they should differ; environment-specific configuration that wasn't validated.

Related errors


AI-assisted analysis of HangfireIO/Hangfire@c236dd0f93 (2026-08-13). Data as JSON: /api/errors/49739787676f90a9. Report an issue: GitHub.