I know I can specify the list of HTTP error codes (e.g. 408, 502, 503, etc. ) I would like to get retried using Polly, but what is the list of these codes that would be retried by default if none is specified?
Asked
Active
Viewed 9,425 times
1 Answers
12
What is the list of [Http status] codes that would be retried by default [by Polly] if none is specified?
Polly on its own contains no built-in definitions of what it retries, you as the user specify that when defining a policy.
Polly with HttpClientFactory (using services.AddHttpClient(...).AddTransientHttpErrorPolicy(...)
in StartUp
in .Net Core) retries the following items, per the Polly with HttpClientFactory documentation:
- Network failures (System.Net.Http.HttpRequestException)
- HTTP 5XX status codes (server errors)
- HTTP 408 status code (request timeout)
This should also be shown in the intellisense when you hover over the method.
The HandleTransientHttpError()
method available via the Polly.Extensions.Http
package also handles the same set of exceptions and status codes.

Amir Mahdi Nassiri
- 1,190
- 13
- 21

mountain traveller
- 7,591
- 33
- 38
-
It seems that polly throws only about timedoutexceptions. Not about the other error codes – Royi Namir Jun 03 '21 at 11:10
-
Can you please have a look at [this](https://stackoverflow.com/questions/67835490/polly-wont-throw-on-some-exceptions) ? – Royi Namir Jun 04 '21 at 10:15
-
1to retry all 5xx errors is too broad list(e.g. 501 NotImplemented doesn’t make sense to retry). Consider https://stackoverflow.com/questions/51770071/what-are-the-http-codes-to-automatically-retry-the-request/74627395#74627395 list instead and retryHttpStatusCodesList implementation from https://stackoverflow.com/questions/61019007/how-to-set-polly-retry-for-the-set-specific-statuscodes-only question – Michael Freidgeim Mar 05 '23 at 21:19