← Guides

How to get a static outbound IP for Vercel Functions

Your Vercel Function authenticates fine, but the partner API still blocks it because the request comes from an IP it does not know. Vercel has two native fixes, and a proxy is a third. Here is how to pick one, set it up step by step, and test it before you touch the allowlist.

Updated 2026-11-23 · 8 min read

First, find out which part makes the request

Code in the browser uses the visitor’s connection. A Vercel Function uses Vercel’s network. A build step that fetches data uses the build network. An allowlist only helps the path that actually opens the connection, so start with the request that fails.

Then ask the API or database owner two things: do they accept one IPv4, a list, or ranges? And is your code making an HTTPS request or opening a native database connection? For HTTPS you can change one HTTP client. A database driver needs a different approach (see the FAQ).

Your options

Option 1: turn on Vercel Static IPs

  1. Open the project, click Settings at the bottom of the sidebar, then Networking. Turn on Advanced Networking.
    Vercel project Settings, Networking: the Advanced Networking switch highlighted
    Settings → Networking. Turning on Advanced Networking leads to Static IPs (billed per project).
  2. Click Static IPs, then Configure Regions, pick up to three regions close to the service you call, and save. Billing for Static IPs starts here, so we stopped before this step; the labels are from Vercel’s docs.
    You should see: two IP addresses for each region you picked.
  3. Send all of the addresses to the service owner and wait until they are allowlisted. Keep the old entries for now.
  4. Redeploy the project. If builds also call the allowlisted service, open Static IPs → Manage and turn on Use for builds (it is off by default).
Static IPs do not apply to Routing Middleware, which runs at the edge. Make IP-restricted calls from a Vercel Function. If the project is attached to a Secure Compute network, Secure Compute takes precedence.

Option 2: send selected requests through your own static IP

Only the calls that get the proxy dispatcher leave from your static IP. Everything else in your app keeps Vercel’s normal network.

Request route through your static IP Vercel Function your code proxy (HTTPS) Your server 203.0.113.42 from 203.0.113.42 Partner API / DB allows 203.0.113.42
Only the calls you send through the proxy use your static IP. Every other request goes out directly, as before.
  1. Log in to the client area, open My Services and click your server. Scroll to Use your IP from code, n8n, CI or a browser. Under Add a proxy user, type vercel and click Add.
    MazeVPN client area: Add a proxy user, with the name vercel typed in
    You should see: a new card named app-vercel. Names can use letters and digits only, and MazeVPN adds the app- prefix.
  2. On that card, click Copy next to HTTPS proxy (marked Encrypted). The copied URL contains the password, so paste it only into a secret or environment variable, never into code.
    MazeVPN client area: the card of proxy user app-ci with its HTTPS, HTTP and SOCKS5 proxy URLs and Copy buttons
    The card of a new proxy user. The eye icon shows the password; Copy copies the full URL with the password. (Server IP replaced with an example.)
    You should see: a URL like https://app-vercel:…@203.0.113.42:443, where the address is your server’s IP.
  3. In Vercel, open the project and click Environment Variables in the sidebar, then Add Environment Variable.
    Vercel project sidebar with Environment Variables highlighted
  4. Keep the type Secret, enter MAZE_PROXY_URL as the Key, paste the URL as the Value, choose the Environments (for a first test, Preview only) and click Save.
    Vercel Add Environment Variable form: type Secret, key MAZE_PROXY_URL, an example value and the Environments selector
    Secret is the default type; the value cannot be shown again after saving.
    You should see: MAZE_PROXY_URL in the list. As a secret, its value cannot be shown again.
  5. Install undici in the project: npm install undici. Put this helper in server-only code (for example lib/partner.js). Replace the URL with an endpoint you are allowed to call.
    import net from 'node:net';
    import tls from 'node:tls';
    import { fetch, ProxyAgent } from 'undici';
    
    // For an HTTPS proxy addressed by IP, undici sends the IP as the TLS server name
    // and Node rejects it. Send a placeholder name and verify the certificate against the IP.
    function proxyAgent(proxyUrl) {
      const { protocol, hostname } = new URL(proxyUrl);
      if (protocol !== 'https:' || !net.isIP(hostname)) return new ProxyAgent(proxyUrl);
      return new ProxyAgent({
        uri: proxyUrl,
        proxyTls: {
          servername: 'proxy.invalid',
          checkServerIdentity: (_name, cert) => tls.checkServerIdentity(hostname, cert),
        },
      });
    }
    
    let dispatcher;
    
    export async function fetchPartnerStatus() {
      if (!process.env.MAZE_PROXY_URL) throw new Error('MAZE_PROXY_URL is required');
      dispatcher ??= proxyAgent(process.env.MAZE_PROXY_URL);
      const response = await fetch('https://api.example.com/status', {
        dispatcher,
        signal: AbortSignal.timeout(10_000),
      });
      if (!response.ok) throw new Error('Partner status: ' + response.status);
      return response.json();
    }
  6. Redeploy: open Deployments, click the … menu of the latest deployment and choose Redeploy (or push a new commit). Vercel does not apply changed environment variables to existing deployments.
    Vercel Deployments page: the deployment menu with Redeploy highlighted
    Deployments → the … menu of the latest deployment → Redeploy.
    You should see: a new deployment with status Ready.

Test before you change the allowlist

  1. In a protected preview deployment, add a temporary function that calls https://ifconfig.me/ip with the same dispatcher and returns the text. Open it once.
    You should see: your server’s IP (the Host shown in the client area), not a Vercel address.
  2. Ask the partner to allowlist that single IPv4, then make one real read-only call through the dispatcher.
    You should see: a normal response instead of a 403 or timeout.
  3. Delete the temporary function, test every region and environment you use, and only then remove old allowlist entries.

Official references

Skip the setup

A dedicated IPv4 in 38 cities, usually ready about 3 minutes after payment. Connect devices with WireGuard and apps with an authenticated HTTPS, HTTP, or SOCKS5 proxy. From $9.99/month.

FAQ

Questions, answered.

Something else? Open a ticket, a human replies.

Can the proxy cover a database connection? +

No. The undici dispatcher only affects HTTP requests that use it. A native database driver needs its own proxy support (some drivers support SOCKS5), a tunnel, or native fixed egress such as Vercel Static IPs.

Why does it work locally but fail on Vercel? +

Locally, requests come from your own network. On Vercel, check that the variable is set for that environment, that you redeployed after setting it, and which IP the deployed function actually shows.

Are Vercel Static IPs only mine? +

No. Vercel says each region provides two addresses from a shared pool. Treat the allowlist as an extra layer and keep authentication in place.

What does MazeVPN cost for this? +

Solo is $9.99 a month with one dedicated IPv4 and three proxy users. Some cities cost extra and every plan has a monthly transfer allowance. See the pricing page.

More guides