---
title: Setting up redundant origin servers
summary: null
url: >-
  https://www.fastly.com/documentation/guides/full-site-delivery/domains-and-origins/setting-up-redundant-origin-servers
---

Sometimes you want to set up two different origin servers, one as a primary and one as a backup in case the primary becomes unavailable. You can do this via the Fastly control panel or using custom VCL.

> **HINT:** Each Fastly service can be configured with up to five origin servers. Contact [sales@fastly.com](mailto:sales@fastly.com) to enable more than five origin servers per service in your account.

## Using the Fastly control panel

Set up redundant origins via the Fastly control panel using these steps.

1.   Log in to the [Fastly control panel](https://manage.fastly.com).

2.   From the [**Home**](https://manage.fastly.com/home) page, select the appropriate service. You can use the search box to search by ID, name, or domain.

3.   Click **Edit configuration** and then select the option to clone the active version.

4.   Click **Origins**.

5. In the **Health Checks** area, define a [health check](https://www.fastly.com/documentation/guides/getting-started/hosts/working-with-health-checks) and assign it to the primary origin server.

6. In the **Hosts** area, find your secondary origin server and click **Attach a condition**.

   ![an example secondary origin server](/img/origins-hosts-secondary-origin.png)

7. Click **Create a new request condition**.

   ![an example create a new condition window](/img/create-a-new-request-condition-primary-unhealthy.png)

8. Fill out the **Create a new request condition** fields as follows:
   - In the **Name** field, enter the name of your request condition (for example, `Primary Unhealthy`).
   - In the **Apply if** field, enter `!req.backend.healthy`.

9. Click **Save and apply to**. The Hosts area now displays the condition that must be met (Primary Unhealthy) in order for your secondary origin server to begin being used.

   ![hosts condition primary unhealthy that will trigger use of the secondary origin server](/img/hosts-if-primary-unhealthy-then-secondary.png)

   Once you've added the condition to your secondary origin server, the VCL generated by Fastly will reflect the new condition.

10. [Preview the VCL](https://www.fastly.com/documentation/guides/full-site-delivery/fastly-vcl/working-with-custom-vcl#previewing-vcl-before-activation), and confirm the following snippets appear in `vcl_recv`:

    ```vcl
    # default conditions
    set req.backend = F_primary;
    ```

    ```vcl
    # Request Condition: primary unhealthy Prio: 10
    if (!req.backend.healthy) {
      set req.backend = F_secondary;
    }
    #end condition
    ```

## Using custom VCL

Set up redundant origins with custom VCL using these steps.

1. In the Fastly control panel, define a [health check](https://www.fastly.com/documentation/guides/getting-started/hosts/working-with-health-checks) and assign it to the primary origin server.

2. Copy the boilerplate VCL from our guide on [mixing Fastly VCL with custom VCL](https://www.fastly.com/documentation/guides/full-site-delivery/fastly-vcl/about-fastly-vcl/), and paste it into a new file.

3. Replace the `vcl_recv` sub with:

   ```vcl
   sub vcl_recv {
   #FASTLY recv
     set req.backend = F_<primary_origin>;
     if (!req.backend.healthy) {
       set req.backend = F_<secondary_origin>;
     }
     if (req.method != "HEAD" && req.method != "GET" && req.method != "FASTLYPURGE") {
       return(pass);
     }
     return(lookup);
   }
   ```

   To find the exact backend names, [view the generated VCL](https://www.fastly.com/documentation/guides/full-site-delivery/fastly-vcl/working-with-custom-vcl#previewing-vcl-before-activation).

4. [Upload](https://www.fastly.com/documentation/guides/full-site-delivery/fastly-vcl/working-with-custom-vcl) your VCL file.
