---
title: "How to configure custom retry policies and disable automatic retries in Hangfire?"  
description: "How to configure custom retry policies and disable automatic retries in Hangfire?"  
author: "Manish Sharma"  
published: 2026-09-17  
updated: 2026-09-17  
canonical: https://www.mindstick.com/forum/162173/how-to-configure-custom-retry-policies-and-disable-automatic-retries-in-hangfire  
category: "Hangfire"  
tags: ["Hangfire", "AutomaticRetry", "Error Handling", "ASP.NET Core", "Background Tasks"]  
reading_time: 1 minute  

---

# How to configure custom retry policies and disable automatic retries in Hangfire?

In my ASP.NET Core application, some long-running background tasks fail due to transient network errors, while others fail due to unrecoverable business validation issues. By default, Hangfire retries failed jobs up to 10 times.

## Applying Retry Attributes

I know I can use the **AutomaticRetry attribute** at the method level:

```cs
// Customize retry attempts and strategy for a specific method
[AutomaticRetry(Attempts = 3, OnAttemptsExceeded = AttemptsExceededAction.Delete)]
public void ProcessPayment(int orderId)
{
    // Payment processing logic
    PaymentGateway.Charge(orderId);
}
```

## Global Configuration Questions

I want to apply a default retry policy globally across all jobs while overriding it for specific background operations. How can I set a global retry attempt limit during registration in `Program.cs`? Also, how can I capture exceptions from a **[failed background job](https://www.mindstick.com/forum/34540/ai)** and send alert notifications to developers before the job is placed in the Deleted state?


---

Original Source: https://www.mindstick.com/forum/162173/how-to-configure-custom-retry-policies-and-disable-automatic-retries-in-hangfire

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
