TemperStack
Intermediate8 min readUpdated Mar 18, 2026

How to configure automatic failover routing on Vercel

Quick Answer

Configure automatic failover routing on Vercel by setting up multiple deployment targets and using Vercel's Edge Config to define routing rules with health checks. This ensures traffic automatically redirects to backup services when your primary deployment fails.

Prerequisites

  1. Active Vercel account with Pro plan or higher
  2. Multiple deployment environments or external services
  3. Basic understanding of DNS and routing concepts
  4. Access to Vercel dashboard and CLI
1

Create Multiple Deployment Targets

Navigate to your Vercel dashboard and create multiple projects or deployment environments. Go to ProjectsNew Project and deploy your application to different regions or create separate backup deployments. Ensure you have at least one primary and one backup deployment with different URLs.
Tip
Deploy your backup instance in a different region for better redundancy
2

Set Up Edge Config Store

In your Vercel dashboard, go to StorageEdge ConfigCreate Store. Name your store (e.g., 'failover-config') and create it. This will store your routing configuration and health check settings that can be accessed globally at the edge.
3

Configure Health Check Endpoints

Create health check API routes in your application by adding files like /api/health.js:

export default function handler(req, res) {
  res.status(200).json({ status: 'healthy', timestamp: Date.now() });
}

Deploy this to all your target environments to enable automated health monitoring.
Tip
Include database connectivity and critical service checks in your health endpoint
4

Create Failover Middleware

Create a middleware.js file in your project root:

import { get } from '@vercel/edge-config';
import { NextResponse } from 'next/server';

export async function middleware(request) {
  const config = await get('failover-config');
  
  if (config?.enableFailover) {
    // Check primary service health
    const healthCheck = await checkHealth(config.primaryUrl);
    
    if (!healthCheck.healthy) {
      return NextResponse.redirect(config.backupUrl);
    }
  }
  
  return NextResponse.next();
}
Tip
Add timeout settings to prevent health checks from blocking requests too long
5

Configure Edge Config Values

In your Edge Config store, add the following configuration:

{
  "enableFailover": true,
  "primaryUrl": "https://your-primary-app.vercel.app",
  "backupUrl": "https://your-backup-app.vercel.app",
  "healthCheckInterval": 30000,
  "timeout": 5000
}

Click Save to apply the configuration.
6

Connect Edge Config to Your Project

Go to your project settings → Environment VariablesAdd New. Add EDGE_CONFIG as the key and paste the connection string from your Edge Config store. Apply this to all environments (Production, Preview, Development).
Tip
Test the connection by using the Vercel CLI command: vercel env pull
7

Set Up Custom Domain Routing

In your project settings, go to Domains and configure your custom domain to point to your primary deployment. Set up DNS records with your domain provider to use Vercel's nameservers. This ensures failover routing works with your custom domain.
Tip
Use CNAME records instead of A records for better flexibility with Vercel's infrastructure
8

Test and Monitor Failover

Deploy your changes and test the failover by temporarily disabling your primary service. Monitor the behavior using Vercel's FunctionsLogs section. Set up monitoring alerts by integrating with services like DataDog or using Vercel's built-in analytics to track failover events.
Tip
Create automated tests that simulate outages to verify your failover setup works correctly

Troubleshooting

Middleware not executing failover logic
Ensure your middleware.js file is in the project root and includes the correct export const config matcher. Verify Edge Config connection string is properly set in environment variables.
Health checks timing out
Reduce the timeout value in your Edge Config and ensure your health check endpoints respond quickly. Add error handling to prevent middleware from blocking all requests during network issues.
Failover not working with custom domains
Verify your DNS settings point to Vercel's nameservers and check that both primary and backup deployments are accessible via HTTPS. Ensure SSL certificates are properly configured for all domains.
Edge Config updates not reflecting immediately
Edge Config changes can take up to 30 seconds to propagate globally. Use the Vercel CLI command vercel edge-config ls to verify your configuration is updated and wait for propagation before testing.

Related Guides

More Vercel Tutorials

Other Tool Tutorials

Ready to get started with Vercel?

Put this tutorial into practice. Visit Vercel and follow the steps above.

Visit Vercel