---
title: "Configure error codes for xConnect transient faults"
slug: "configure-error-codes-for-xconnect-transient-faults"
abstract: "How to change the response error codes xConnect identifies as transient errors for fault handling."
---
# Configure error codes for xConnect transient faults

You can overwrite the [default error response codes](https://doc.sitecore.com/xp/en/developers/105/sitecore-experience-platform/http-transient-fault-handling-for-xconnect-clients.html#UUID-fd8a0ace-dd83-bfae-6f7d-4b17ed37c5ad_section-idm4568354053432033339696989659 "Default transient error status codes") the retryer uses to identify xConnect client transient errors, with the error response codes of your choice. For example, you can add new error response codes, or remove some of the existing codes.

There are two ways to do this. You can either change the retryer configuration [in the xConnect client configuration file](https://doc.sitecore.com/xp/en/developers/105/sitecore-experience-platform/configure-error-codes-for-xconnect-transient-faults.html#UUID-a3e272a9-41e5-be1a-26e8-502d4892947e_section-idm4650011040755233339708471711 "Update the xConnect Client configuration to add or remove transient error response codes"), or you can add new HTTP error codes [using the C# language](https://doc.sitecore.com/xp/en/developers/105/sitecore-experience-platform/configure-error-codes-for-xconnect-transient-faults.html#UUID-a3e272a9-41e5-be1a-26e8-502d4892947e_section-idm4590504614526433370940984844 "Add new HTTP error codes using C# code").

<details>
<summary><h2>Update the xConnect Client configuration to add or remove transient error response codes</h2></summary>

To configure transient error response codes:

1. Open the `C:\path\to\sitecore\App_Config\Sitecore\XConnect.Client.Configuration\Sitecore.XConnect.Client.config.Sitecore.XConnect.Client.config` file.
2. In the xConnect client retryer configuration options, in the `<CustomCodes>` section, remove any unwanted error codes, and add new custom codes as required. For example, in the following configuration, we removed the default error code `<RequestTimeout>408</RequestTimeout>`, and added the new error code `<InternalServerError>500</InternalServerError>`:

    ```xml
    <CustomCodes>                       
          <GatewayTimeout>504</GatewayTimeout>             
          <BadGateway>502</BadGateway>             
          <TooManyRequests>429</TooManyRequests>
          <InternalServerError>500</InternalServerError>      
          <ServiceUnavailable>503</ServiceUnavailable>
     </CustomCodes>
    ```

</details>

<details>
<summary><h2>Add new HTTP error codes using C# code</h2></summary>

You can use C# code to overwrite the error response codes defined by the default retryer.

To add new HTTP error codes using C# code:

- In your C# code, specify the HTTP response status codes that the detection strategy must treat as transient errors. The following code sample overwrites the default retryer configuration, and instead only handles the following 2 types of errors: HTTP internal server error, and gateway timeout:

    ```csharp
    services.AddTransientFaultHandling(config
    => config 
    .AddDefaultHttpRetryer("MyRetryer", new
    HttpPolicyRetryerOptions
    {   
    ExponentialRetry = new ExponentialRetryOptions   
    {     
    MaxAttempts = 3,     
    MinBackoff = TimeSpan.FromSeconds(5),     
    MaxBackoff = TimeSpan.FromSeconds(30),    
    DeltaBackoff = TimeSpan.FromSeconds(1)   
    },   
    CustomCodes = new
    List<HttpStatusCode>
        {      
          HttpStatusCode.InternalServerError,
          HttpStatusCode.GatewayTimeout
        }
       });
    ```

</details>