Hangfire Recurring Jobs Missing After a Deploy: Causes and an Audit
Contents
When Hangfire recurring jobs go missing after a deploy, the entries in storage no longer match what your code registers: the registration didn't run in the new version, it wrote to different storage, an ID changed, or cleanup code removed entries it shouldn't have. Hangfire stores recurring jobs by ID and never removes one on its own, so every disappearance has a cause in your code, your configuration, or your deployment. Compare the IDs your code registers with the IDs in storage on every startup, and the cause is usually obvious.
This guide covers Hangfire 1.8, with source links to 1.8.25, the latest 1.8 release on NuGet when checked on November 16, 2026. Hangfire recurring job not running covers the full list of reasons a recurring job doesn't run; this post goes deeper on the ones a deployment introduces.
What a Deploy Can Change#
A recurring job exists in Hangfire only as an entry in storage, created or updated when AddOrUpdate runs and removed when RemoveIfExists runs or someone clicks Delete in the dashboard (RecurringJobManager.cs). A deploy affects that in four ways:
| After the deploy | Cause | Section |
|---|---|---|
| Some jobs missing, others fine | Registration moved, conditional, or stopped partway | 1 |
| New entry plus an old one that errors or does nothing | The recurring job ID changed | 2 |
| Jobs present at startup, gone minutes later | A cleanup loop removed them | 3 |
| Dashboard shows few or no jobs, old ones still run | Different storage, schema, or prefix | 4 |
| Jobs flip between versions, or error then disable | Two code bases or two versions on one storage | 5 |
1. The Registration Didn't Run in the New Version#
Registration is ordinary startup code, so anything that changes startup can skip it:
- It moved. Registration that moved from the web app to a worker service, or into a module that's now loaded from another assembly, runs only where that code is deployed and started. If the worker deploy failed or lagged behind the web deploy, the entries aren't refreshed, and new ones never appear.
- It's behind a condition.
if (app.Environment.IsProduction()), a feature flag, or a configuration section that's absent in the new environment's settings. - It stopped partway.
AddOrUpdatevalidates the cron expression and throwsArgumentExceptionfor an invalid one. In a loop over job definitions, the first bad expression throws and every job after it isn't registered. If the exception is caught and logged at startup, the app starts normally with part of its schedule. - It runs before storage is configured. The static
RecurringJobAPI throwsInvalidOperationExceptionwhenJobStorage.Currentisn't set yet. ResolvingIRecurringJobManagerfrom dependency injection avoids the ordering problem.
Registering each job from one list, with a separate try/catch per job, turns a partial registration into a log line per failed job instead of silent truncation:
using Hangfire;
using Microsoft.Extensions.Logging;
public sealed record RecurringJobDefinition(string Id, string Cron, Action<IRecurringJobManager, string, string> Register);
public static class RecurringJobRegistry
{
public static readonly IReadOnlyList<RecurringJobDefinition> All = new[]
{
new RecurringJobDefinition("nightly-report", "0 2 * * *",
(m, id, cron) => m.AddOrUpdate<ReportJobs>(id, jobs => jobs.SendNightlyReport(), cron)),
new RecurringJobDefinition("hourly-usage-rollup", "0 * * * *",
(m, id, cron) => m.AddOrUpdate<UsageJobs>(id, jobs => jobs.RollUpUsage(), cron)),
};
public static void RegisterAll(IRecurringJobManager manager, ILogger logger)
{
foreach (var job in All)
{
try
{
job.Register(manager, job.Id, job.Cron);
}
catch (Exception error)
{
logger.LogError(error, "Recurring job {JobId} was not registered", job.Id);
}
}
}
}
public class ReportJobs
{
public void SendNightlyReport() => Console.WriteLine("Sending the nightly report");
}
public class UsageJobs
{
public void RollUpUsage() => Console.WriteLine("Rolling up usage");
}The same list gives the audit in a later section its expected set of IDs.
2. A Renamed ID Leaves an Orphan#
A recurring entry is keyed on its ID. AddOrUpdate with a new ID creates a new entry; it doesn't rename the old one. Change nightly-report to reports-nightly and storage now holds both. What happens to the old one depends on what else changed:
- Only the ID changed. The old entry still points at a valid method, so both run, and the job runs twice per schedule.
- The method or class was renamed too. The old entry can't be loaded. When it's due, the scheduler logs that it "can't be scheduled due to an error," retries at the polling interval (15 seconds by default), and after five retries disables it and keeps the error (RecurringJobScheduler.cs).
Implicit IDs make this happen without anyone choosing a new ID. Hangfire 1.8 made the AddOrUpdate overloads without an explicit ID obsolete; for non-generic methods they derived the ID from {TypeName}.{MethodName} (1.8.0 announcement), so a refactor that renamed either changed the ID. Use explicit, stable IDs, and when you do rename one, remove the old ID in the same release:
// The old ID is gone from code; remove its entry so it can't run or fail.
recurringJobs.RemoveIfExists("nightly-report");Also check case. The recurring-task docs warn that IDs may be case sensitive in some storage implementations, so Nightly-Report and nightly-report can be two entries.
3. A Cleanup Loop Removed the Jobs#
Teams that rename jobs often add a loop at startup that removes every entry not in the current code:
// Risky: removes anything this process doesn't know about, including other apps' jobs.
using var connection = JobStorage.Current.GetConnection();
foreach (var job in connection.GetRecurringJobs())
{
if (!knownIds.Contains(job.Id))
{
RecurringJob.RemoveIfExists(job.Id);
}
}The loop is only as correct as knownIds, and deployments are when it's wrong:
- Another process registers some jobs. If the web app and a worker service each register their own jobs, each one's loop deletes the other's, and whichever starts last wins until the other restarts.
- The old version is still running. During a rolling deploy, an old instance that restarts runs the old loop with the old list and removes jobs the new version just added.
- Libraries register jobs too. Packages that add their own recurring jobs, such as CronRadar.Hangfire's
cronradar:reconcile, are removed by a loop that doesn't know their IDs. They come back only when their package re-registers them, typically at the next startup. - The list was built before registration. A loop that runs before modules register their jobs sees an incomplete list.
Safer patterns: remove specific retired IDs explicitly, as in section 2, rather than "everything unknown." If you need a sweep, limit it to IDs with your own prefix, such as billing:, and run it only from the one service that owns that prefix.
4. The New Version Points at Different Storage#
The dashboard shows only the storage it's connected to. After a deploy that changed any of these, it can show an empty or partial list while the old entries are untouched somewhere else:
- The connection string, for example a new
appsettings.Production.json, a renamed secret, or a database moved to a new server. - The SQL Server
SchemaName, defaultHangFire(Constants.cs), changed in options. - The Redis
Prefix, defaulthangfire:(Redis docs), or the Redis database number. - The storage provider itself, such as a move from SQL Server to PostgreSQL storage.
Two dangers follow. The jobs the new storage lacks don't run. And if anything still runs a Hangfire server against the old storage, such as an instance that wasn't redeployed, the old entries keep running there with old code, out of sight of the new dashboard. Log the storage target at startup (server, database, schema or prefix, never the password) so both are visible.
5. Two Code Bases or Two Versions Share One Storage#
Any server's recurring job scheduler can pick up any entry in its storage. If two applications, or two branches of one application, share a storage, a server whose code lacks an entry's type fails to schedule it and, after five retries, disables it. The 1.8.0 announcement is explicit: "it's still impossible to use the same storage for recurring jobs from different code bases." Give each code base its own storage, schema, or prefix.
The same thing happens briefly in every rolling deploy: old and new instances overlap, and an old instance that can't load a newly added or renamed type records the error. Five retries at 15 seconds take little more than a minute, so a long overlap can disable a new job before any new instance re-registers it. Re-registering the entry with AddOrUpdate clears the error, so restarting a new instance after the old ones are gone fixes it; shortening the overlap prevents it.
Compare Code With Storage on Every Startup#
All five causes show up the same way in an audit: a list of IDs your code expects, a list of IDs in storage, and the entries whose state is wrong. StorageConnectionExtensions.GetRecurringJobs() returns each entry as a RecurringJobDto with Id, Cron, Queue, NextExecution, LastExecution, LastJobState, Error, RetryAttempt, LoadException, and TimeZoneId (StorageConnectionExtensions.cs):
using Hangfire;
using Hangfire.Storage;
using Microsoft.Extensions.Logging;
public static class RecurringJobAudit
{
// Call after registration, with the JobStorage from dependency injection.
public static void Run(JobStorage storage, IEnumerable<string> expectedIds, ILogger logger)
{
using var connection = storage.GetConnection();
var stored = connection.GetRecurringJobs().ToDictionary(job => job.Id);
var expected = expectedIds.ToHashSet();
foreach (var id in expected.Where(id => !stored.ContainsKey(id)))
{
logger.LogError("Recurring job {JobId} is registered in code but missing from storage", id);
}
foreach (var job in stored.Values.Where(job => !expected.Contains(job.Id)))
{
logger.LogWarning("Recurring job {JobId} is in storage but not in this code base (cron {Cron})", job.Id, job.Cron);
}
foreach (var job in stored.Values)
{
if (job.LoadException != null || !string.IsNullOrEmpty(job.Error))
{
logger.LogError("Recurring job {JobId} can't be scheduled: {Error}",
job.Id, job.Error ?? job.LoadException?.Message);
}
else if (job.NextExecution == null)
{
logger.LogWarning("Recurring job {JobId} has no next execution", job.Id);
}
}
logger.LogInformation("Recurring job audit: {Expected} expected, {Stored} in storage", expected.Count, stored.Count);
}
}Wire it in after registration:
using Hangfire;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHangfire(config => config
.UseSqlServerStorage(builder.Configuration.GetConnectionString("Hangfire")));
builder.Services.AddHangfireServer();
var app = builder.Build();
var recurringJobs = app.Services.GetRequiredService<IRecurringJobManager>();
var logger = app.Services.GetRequiredService<ILoggerFactory>().CreateLogger("RecurringJobs");
RecurringJobRegistry.RegisterAll(recurringJobs, logger);
RecurringJobAudit.Run(
app.Services.GetRequiredService<JobStorage>(),
RecurringJobRegistry.All.Select(job => job.Id),
logger);
app.Run();"In storage but not in this code base" is expected for library jobs and for other services that share the storage, so read it as a list to review, not an error. The audit runs only at startup. It catches what this version did to storage; a cleanup loop or dashboard Delete afterward needs something that keeps watching.
How Monitoring Shows a Job That Vanished#
CronRadar.Hangfire 0.2.1 builds monitors from the same registry the audit reads. Add it after AddHangfire() in the host that runs the server:
using CronRadar.Hangfire;
using Hangfire;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHangfire(config => config
.UseSqlServerStorage(builder.Configuration.GetConnectionString("Hangfire")));
builder.Services.AddHangfireServer();
// Reads the application key from the CRONRADAR_API_KEY environment variable.
builder.Services.AddCronRadarHangfire();
var app = builder.Build();
app.Run();At startup it declares every recurring job and its cron expression to CronRadar, then reconciles the registry every 15 minutes through its own recurring job, cronradar:reconcile. A server filter reports each run's start, completion, or failure. Against the causes above:
- A job removed from storage (sections 1, 3, 4): when a later reconciliation no longer contains a recurring-job ID, CronRadar pauses that monitor, keeps its history, and marks it as no longer discovered. A paused monitor doesn't send missed-run alerts, because the job is no longer scheduled; the pause is the record that it disappeared.
- A renamed ID (section 2): the new ID gets a new monitor, and the old ID's monitor is paused at the next reconciliation, or keeps alerting if the old entry is still in storage but can't run.
- A job that stays in storage but stops running (section 5, an entry disabled by scheduler errors): no start arrives, so after the expected time plus the grace period the monitor goes from
warningtocriticaland alerts by email, Slack, webhook, Discord, or PagerDuty. A failure after Hangfire's retries are exhausted alerts immediately.
Because removals pause rather than alert, check paused monitors after each deploy. The sync status endpoint lists every monitor with isPaused and status:
curl --fail-with-body --silent --show-error \
--user "$CRONRADAR_API_KEY:" \
"https://cron.life/api/v1/sync/status" \
| jq -r '.monitors[] | select(.isPaused) | "\(.monitorKey)\t\(.updatedAt)"'A key that was active before the deploy and is paused after it is a job the deploy removed. Keep cronradar:reconcile out of any cleanup loop; if one removes it, reconciliation stops until the next startup re-registers it. Opt a job out with [SkipMonitor] on its method. Only recurring jobs are discovered, not one-time Enqueue or Schedule jobs. The Hangfire integration guide covers setup; use a separate CronRadar application and key per environment, so a staging deploy can't pause production monitors.
Frequently Asked Questions#
Why did my Hangfire recurring jobs disappear after deployment?#
Hangfire never removes recurring entries by itself, so something in the deploy did: registration code that didn't run in the new version, a cleanup loop calling RemoveIfExists with an incomplete list, a changed recurring job ID, or a new connection string, schema, or prefix that points the app at different storage. Compare the IDs your code registers with GetRecurringJobs() from the storage the server uses.
How do I list all Hangfire recurring jobs in code?#
Open a storage connection and call the GetRecurringJobs() extension method from the Hangfire.Storage namespace: using var connection = storage.GetConnection(); var jobs = connection.GetRecurringJobs();. Each RecurringJobDto has the ID, cron expression, queue, next and last execution, last job state, and any scheduling error.
Does renaming a Hangfire recurring job ID delete the old job?#
No. AddOrUpdate with a new ID creates a second entry, and the old one stays scheduled until something calls RemoveIfExists with the old ID or deletes it in the dashboard. If the old entry's method was renamed too, it starts failing to schedule and is disabled after five retries.
Is it safe to remove recurring jobs that aren't in code at startup?#
Only if this process is the sole owner of every recurring job in that storage. A sweep that removes unknown IDs also removes jobs registered by other services, by libraries, and by newer versions during a rolling deploy. Remove retired IDs explicitly, or restrict any sweep to an ID prefix that one service owns.
Can two applications share one Hangfire storage for recurring jobs?#
Not safely. Any server's scheduler can pick up any recurring entry, and a server whose code doesn't contain the entry's type fails to schedule it and eventually disables it. Hangfire's 1.8.0 announcement says it's still impossible to use one storage for recurring jobs from different code bases; give each its own storage, schema, or prefix.
Put this guide to work
Connect your Hangfire job to monitoring
Follow the current integration guide, check the release limitations, and verify a real run and alert delivery.
NuGet installs CronRadar.Hangfire 0.2.2. Failures are reported only after Hangfire finishes retrying, including cancellations. Discovered monitors start with a 60-second grace period unless the code sets another; a grace period or schedule edited in the dashboard stays until the code declares a different value.