---
title: Egress Firewall
description: Use Egress Firewall to control which destinations your Vercel Functions and sandboxes can connect to with a shared, versioned network policy.
url: "https://vercel.com/docs/vercel-firewall/egress-firewall"
last_updated: 2018-10-20
related:
  - /docs/functions
  - /docs/sandbox
  - /docs/vercel-firewall
  - /docs/release-phases
  - /docs/project-configuration/vercel-json
install_vercel_plugin: npx plugins add vercel/vercel-plugin
search_with_vercel_cli: npx vercel@latest docs search "<query>"
search_kb_with_vercel_cli: npx vercel@latest kb search "<query>"
---

# Egress Firewall

Egress Firewall controls which destinations your [Vercel Functions](/docs/functions) and [sandboxes](/docs/sandbox) can connect to. You define the allowed destinations in a network perimeter, then attach that perimeter to the workloads it should cover. Vercel blocks every outbound connection the perimeter doesn't allow.

The [Vercel Firewall](/docs/vercel-firewall) filters the requests coming in to your applications. Egress Firewall controls the connections your compute makes out, which limits where a compromised dependency or a misconfigured integration can send data.

Egress Firewall is in [private beta](/docs/release-phases#private-beta). It covers Vercel Functions and sandboxes today, and support for builds is coming soon.

## How Egress Firewall works

A perimeter is a network policy and an outbound route that your team owns. Each perimeter has four parts:

- **Policy**: Which destinations workloads can reach
- **Routing**: Where allowed traffic leaves Vercel's network
- **Projects**: Which projects, and which of their workload types, can use the perimeter
- **Versions**: A revision for every configuration change, with the option to roll back

Vercel enforces the policy for the workload, so your application code doesn't change. You can create as many perimeters as you need, for example one for regulated workloads and another for internal tools.

## Running a workload in a perimeter

To get started, follow these steps:

### Create a perimeter

1. From your team's [dashboard](/dashboard), open [**Egress Firewall**](/d?to=%2F%5Bteam%5D%2F%7E%2Fegress-firewall\&title=Open+Egress+Firewall) in the sidebar.
2. Select **Create Perimeter**.
3. Enter a name that describes the workloads the perimeter protects, such as `payments-prod`. Names use lowercase letters, numbers, and hyphens, and start and end with a letter or number.
4. Select **Create Perimeter**.

A new perimeter routes to the public internet with no restrictions, so attaching it to a workload doesn't block anything until you [change its policy](#choose-what-a-perimeter-allows).

Each perimeter has an ID that starts with `pmtr_`. Copy the ID from the perimeter's page. You use it to attach the perimeter to a workload.

### Allow projects to use a perimeter

A workload can only use a perimeter after you grant its project access. To allow a project:

1. Open the perimeter's **Projects** tab and select **Allow Project**.
2. Pick one or more projects, or select **All projects** to cover every project in your team.
3. Under **Workloads**, choose which workload types can use the perimeter, such as **Functions** or **Sandboxes**.
4. [Save your changes](#save-your-changes).

Allowing a project to use a perimeter doesn't automatically attach its workloads. You must attach workloads separately, as described in the next steps.

The **Projects** tab shows whether each allowed workload type used the perimeter in the past 24 hours.

You can't currently attach builds to a perimeter. Support for builds is coming soon.

### Attach a perimeter to Vercel Functions

Set `perimeter` to the perimeter's ID on any entry under [`functions`](/docs/project-configuration/vercel-json#functions) in your project configuration:

#### vercel.json

```json filename="vercel.json"
{
  "$schema": "https://openapi.vercel.sh/vercel.json",
  "functions": {
    "api/private/*.js": {
      "perimeter": "pmtr_0123456789abcdefghijklmnopqr",
      "maxDuration": 30
    },
    "api/public/*.js": {
      "maxDuration": 60
    }
  }
}
```

#### vercel.ts

```typescript filename="vercel.ts"
import type { VercelConfig } from '@vercel/config/v1';

export const config: VercelConfig = {
  functions: {
    'api/private/*.js': {
      perimeter: 'pmtr_0123456789abcdefghijklmnopqr',
      maxDuration: 30,
    },
    'api/public/*.js': {
      maxDuration: 60,
    },
  },
};
```

#### vercel.toml

```toml filename="vercel.toml"
"$schema" = "https://openapi.vercel.sh/vercel.json"

[functions."api/private/*.js"]
perimeter = "pmtr_0123456789abcdefghijklmnopqr"
maxDuration = 30

[functions."api/public/*.js"]
maxDuration = 60
```

In this example, the functions under `api/private` can reach only the destinations the perimeter allows. The functions under `api/public` have no perimeter and keep unrestricted outbound access.

Each key is a glob pattern that matches function paths, the same kind you use to set `maxDuration` or `regions`. This gives you control over each route handler:

- **Protect one route first**: Limit the handler that charges a card to your payment processor, and leave the rest of your application unchanged.
- **Use different perimeters in one project**: Give each group of functions the perimeter that matches the destinations it needs. One deployment can use up to 10 perimeters.
- **Match framework paths**: In a Next.js project, `app/api/**/*` matches every route handler under `app/api`.

The following rules apply when you attach a perimeter to a function:

- The `perimeter` value must be the perimeter's ID. You can't use the perimeter's name.
- The perimeter must [allow the project](#allow-projects-to-use-a-perimeter) for **Functions**. If it doesn't, the build fails.
- The attachment takes effect with the deployment that includes the configuration change.
- The functions in one deployment can use up to 10 different perimeters. If they use more, the build fails.
- To detach a perimeter, remove the `perimeter` property and deploy again.

### Attach a perimeter to a sandbox

Create a sandbox with the perimeter's ID as its network ID, set with `networkId` (`network_id` in Python):

**index.ts**

```ts filename="index.ts"
import { Sandbox } from '@vercel/sandbox';

const sandbox = await Sandbox.create({
  networkId: 'pmtr_0123456789abcdefghijklmnopqr',
});
```

**main.py**

```python filename="main.py"
import asyncio

from vercel import sandbox


async def main() -> None:
    box = await sandbox.create_sandbox(
        network_id="pmtr_0123456789abcdefghijklmnopqr",
    )


asyncio.run(main())
```

The perimeter must [allow the project](#allow-projects-to-use-a-perimeter) for **Sandboxes**.

## Choose what a perimeter allows

To build an allowlist without breaking a workload, attach a perimeter while its policy is **Allow All**. Review [**Top Destinations**](#monitor-outbound-traffic) on the perimeter's **Overview** tab to learn which destinations the workload depends on, then switch the policy to **Domains**.

Open the perimeter's **Policy** tab and select one of the four **Outbound access** options:

| Outbound access | What workloads can reach |
| --- | --- |
| **Allow All** | Any public destination. New perimeters start with this option. |
| **Domains** | Only the domains you allow, over TLS. Vercel blocks all other traffic, including plain-text HTTP. |
| **CIDR Ranges** | The IPv4 ranges you allow, except any ranges you deny. |
| **Block All** | Nothing. Vercel blocks every outbound connection, including DNS. |

A perimeter allows either domains or Classless Inter-Domain Routing (CIDR) ranges, and can't combine both. You can deny CIDR ranges with either option.

Vercel always blocks private ranges (RFC 1918 and RFC 6598) unless the perimeter [routes through a Secure Compute network](#route-traffic-through-secure-compute).

### Allow domains

Add each domain your workloads need, such as `api.example.com`. Vercel matches a domain against the hostname in the TLS handshake, known as [Server Name Indication (SNI)](/docs/glossary#sni-server-name-indication).

A domain rule needs that hostname, so **Domains** only allows connections that use TLS and send SNI. Vercel blocks every other connection, even to a domain you allow:

- **Plain-text HTTP**: Vercel blocks a request to `http://api.example.com` when `api.example.com` is allowed. Use `https://` instead.
- **Other protocols without TLS**: Vercel blocks SSH and any protocol that doesn't start with a TLS handshake.
- **TLS without SNI**: Vercel blocks TLS connections that don't send a hostname.

Postgres connections to an allowed domain work when the client requires TLS, with `sslmode=require` or stricter. To allow a protocol that Vercel can't match by domain, select **CIDR Ranges** and allow the destination's IP range.

Use a wildcard to match subdomains. `*.example.com` matches `api.example.com`, and doesn't match `example.com` itself. Add `example.com` separately when your workloads need both.

To block specific addresses, add them under **Denied CIDR Ranges**. Vercel blocks a denied range even when an allowed domain resolves to an address inside it.

### Allow or deny CIDR ranges

Add IPv4 ranges in CIDR notation, such as `203.0.113.0/24`. The following rules apply:

- Once you allow a range, Vercel blocks all traffic outside your allowed ranges.
- Vercel always blocks a denied range, including addresses inside an allowed range.
- If you only deny ranges, workloads can reach every destination except those ranges.
- Each range must align to its prefix. For example, use `10.0.0.0/16`, not `10.0.5.0/16`.
- Ranges in the same list can't overlap. For example, you can't allow both `10.0.0.0/8` and `10.4.0.0/16`.

### Save your changes

Your edits stay unsaved until you review them:

1. Select **Review and Save**.
2. Check the list of changes, and add an optional change message that explains why you're making them.
3. Select **Save Changes**.

Saved changes apply to running workloads without a new deployment.

### Combine a perimeter with a sandbox network policy

A sandbox also has its own network policy, which you set with the [Sandbox firewall](/docs/sandbox/concepts/firewall). When a sandbox uses a perimeter, both apply:

- **Access**: The sandbox's network policy can restrict traffic further than the perimeter. It can't allow a destination the perimeter blocks.
- **Routing**: The perimeter decides where traffic leaves Vercel's network. The sandbox's network policy doesn't change the route.

For example, when a perimeter allows `*.example.com`, a sandbox's network policy can limit that sandbox to `api.example.com`. It can't give the sandbox access to a domain outside `*.example.com`.

Use the perimeter for the limits every sandbox in a project must stay within, and the sandbox's network policy to tailor access for an individual sandbox.

## Choose where traffic leaves Vercel's network

Open the perimeter's **Routing** tab to choose an **Outbound route**. The network policy always applies first, whichever route traffic takes.

### Route traffic to the internet

**Internet** is the default. Allowed traffic goes straight to the public internet from shared, rotating Vercel IP addresses.

### Route traffic through Secure Compute

Select **Secure Compute** to route allowed traffic through your team's [Secure Compute](/docs/networking/secure-compute) networks. This gives your workloads stable outbound IP addresses and access to your VPC peering connections.

This route requires an existing Secure Compute network in your team. To create one, see [Enabling Secure Compute](/docs/networking/secure-compute#enabling-secure-compute).

Choose at least one network. A perimeter can use one network per region, and each workload uses the network in the region closest to where it runs.

Because the route belongs to the perimeter, you can send some functions through Secure Compute and leave the rest on the default route. For example, attach a perimeter that routes through Secure Compute to the functions that call a partner API with an IP allowlist.

### Route traffic by destination

**By Destination** isn't available to every team during the beta. If your perimeter's **Routing** tab shows it, select **By Destination** to pick a default route, then send specific destinations the other way:

1. Choose **Internet** or **Secure Compute** as the **Default Route**.
2. Add the domains or CIDR ranges that take the other route, such as `*.example.com` or `10.0.0.0/16`.

Use this option when only a few destinations need your Secure Compute network. A perimeter supports up to 100 domains and 100 CIDR ranges as exceptions.

## Review changes and roll back

Every configuration change creates a new revision. Open the perimeter's **Versions** tab to see each revision, who made it, and its change message. Select a revision to see what changed.

To restore an earlier configuration:

1. Open the menu on the perimeter's page and select **Rollback**.
2. Choose the revision to roll back to, and review the changes.
3. Select **Rollback**.

A rollback restores the whole configuration, including the policy, the routing, and the allowed projects. It creates a new revision, so you can roll back again. Like any other change, it applies to running workloads without a new deployment.

## Monitor outbound traffic

Open the perimeter's **Overview** tab to see what your workloads connected to in the last hour or the last 24 hours:

- **Traffic summary**: Connections, data sent and received, blocked connections, and the share of connections allowed
- **Top Destinations**: The destinations with the most connections, and the workloads that reached each one
- **Blocked Connections**: The destinations the policy blocked, the workload that tried to reach each one, and when it last tried

During the beta, Vercel keeps a perimeter's traffic data for 24 hours.

## Remove a project from a perimeter

To stop a project from using a perimeter:

1. Detach the perimeter from the project's workloads. Remove the `perimeter` property from the project's [function configuration](#attach-a-perimeter-to-vercel-functions) and deploy again, and stop creating sandboxes with the perimeter's ID as their network ID.
2. Open the perimeter's **Projects** tab, open the project's menu, and select **Remove Project**. To remove one workload type, expand the project and remove that workload.
3. Save your changes.

Removing a project doesn't stop its workloads. The following rules apply to a workload that still references the perimeter:

- **Running instances**: Stay attached to the perimeter and keep following its policy until they stop.
- **New instances**: Start without the perimeter, so the perimeter's policy and routing no longer apply to them.
- **New deployments and sandboxes**: Fail until you allow the project again or detach the perimeter.

## Delete a perimeter

You can't delete a perimeter while it allows any project. To delete a perimeter:

1. [Remove every allowed project](#remove-a-project-from-a-perimeter), including the step that detaches the perimeter from each project's workloads. New deployments and sandboxes that reference a deleted perimeter fail.
2. Open the menu on the perimeter's page and select **Delete Perimeter**.
3. Type the perimeter's name to confirm.

You can't undo deleting a perimeter.

## Who can manage perimeters

Team members with the [Owner or Security role](/docs/rbac/access-roles/team-level-roles) can create, edit, roll back, and delete perimeters. Other team members who can view a perimeter see its configuration and traffic without the edit controls.

## Pricing

Egress Firewall has two charges:

| Charge | Rate | When it applies |
| --- | --- | --- |
| Inspected data | $0.02 per GB | Egress Firewall inspects data for a workload that uses a perimeter |
| Perimeter usage | $1 per hour | At least one workload in your team uses a perimeter during the hour |

A perimeter that no workload uses has no charge.

### Inspected data

Vercel bills $0.02 per GB of data that Egress Firewall inspects.

Two existing data transfer rates already include inspection. When your traffic is billed at one of these rates, you don't pay the $0.02 per GB on top of it:

- **Private Data Transfer**: Traffic that a perimeter routes through a Secure Compute network. See [Secure Compute pricing](/docs/networking/secure-compute#pricing).
- **Sandbox Data Transfer**: Traffic from a sandbox. See [Sandbox pricing](/docs/sandbox/pricing).

### Perimeter usage

Vercel bills $1 for each hour in which a Vercel Function, a sandbox, or any other workload in your team uses a perimeter. This is a flat rate for the team:

- It doesn't increase with the number of perimeters, projects, or workloads.
- One function that uses one perimeter costs the same $1 per hour as many functions and sandboxes that use several perimeters.
- Vercel doesn't bill the hours in which no workload uses a perimeter.

### Example calculation

A team attaches a perimeter to its Vercel Functions. The functions use the perimeter in every hour of a 30-day month and send 100 GB of inspected data to the internet:

| Charge | Calculation | Cost |
| --- | --- | --- |
| Perimeter usage | 720 hours × $1 | $720.00 |
| Inspected data | 100 GB × $0.02 | $2.00 |
| Total | | $722.00 |

### Stop Egress Firewall charges

To stop both charges, detach your perimeters from every workload:

- Remove the `perimeter` property from your [function configuration](#attach-a-perimeter-to-vercel-functions) and deploy again.
- Stop creating sandboxes with a perimeter's ID as their network ID, and stop any running sandboxes that use one.

See [Pricing on Vercel](/docs/pricing) for how Vercel bills usage across products.

## Limits

| Limit | Value |
| --- | --- |
| Perimeter name length | 100 characters |
| CIDR range format | IPv4 only |
| Entries per policy list | 500 in each list of allowed domains, allowed CIDR ranges, or denied CIDR ranges |
| Change message length | 250 characters |
| Perimeters per deployment | 10 |
| Secure Compute networks per perimeter | One per region |
| Routing exceptions per perimeter | 100 domains and 100 CIDR ranges |
| Traffic data retention | 24 hours during the beta |

## More resources

- [Vercel Firewall](/docs/vercel-firewall)
- [Sandbox firewall](/docs/sandbox/concepts/firewall)
- [Secure Compute](/docs/networking/secure-compute)
- [`functions` configuration reference](/docs/project-configuration/vercel-json#functions)
- [Pricing on Vercel](/docs/pricing)

## Search the docs from your terminal

Search the Vercel docs and read pages as Markdown with the Vercel CLI. No login required.

```bash
# Find docs pages by keyword
npx vercel@latest docs search "environment variables"
npx vercel@latest docs search "function timeout"

# Print a docs page as Markdown, by path or URL
npx vercel@latest docs inspect <page>
```

## Search guides from your terminal

Search the Knowledge Base and read guides as Markdown with the Vercel CLI. No login required.

```bash
# Find guides by keyword
npx vercel@latest kb search "rewrites and redirects"
npx vercel@latest kb search "AI SDK streaming"

# Show the latest guides
npx vercel@latest kb

# Print a guide as Markdown, by slug or URL
npx vercel@latest kb inspect <guide>
```

---

[View full sitemap](/docs/sitemap)


If you encounter incorrect information, can’t find what you need, need a capability Vercel doesn’t currently offer, or have any other feedback to report, please do it by following the instructions at https://vercel.com/feedback.md.
