← Guides

How to give Netlify Functions a static outbound IP

A partner API with an IP allowlist keeps rejecting your Netlify site. Before you fix it, check where the request runs: a serverless function, a build and a browser each leave from a different network. Then follow the steps below.

Updated 2026-11-23 · 8 min read

Browser, build or function?

JavaScript in the browser calls APIs from the visitor’s connection. A pre-render step fetches data from Netlify’s build environment. A serverless function calls the API at runtime from Netlify’s function network. Allowlisting one of these does not cover the others.

If a request needs a private API key, move it into a function. Keep that function narrow: one that returns an order status, for example, not one that fetches any URL it is given.

Your options

Option 1: Private Connectivity (Enterprise)

  1. Ask your Netlify account manager to enable it for functions, builds or both (they are separate).
  2. Open Team settings → General → Team details → Private Connectivity and copy the addresses for the function regions or builds you use.
  3. Set the site’s function region to cmh, fra or lhr under Cloud compute → Functions → Region, redeploy, and ask the API owner to allowlist every address for that region.

Option 2: use your own static IP from a function

Request route through your static IP Netlify 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 netlify and click Add.
    MazeVPN client area: Add a proxy user, with the name netlify typed in
    You should see: a new card named app-netlify. 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-netlify:…@203.0.113.42:443, where the address is your server’s IP.
  3. In Netlify, open the project and click Manage in the top bar.
    Netlify project top bar with the Manage button highlighted
  4. Scroll to the section about how the app runs and click the Keys and secrets card, then Add a key.
    Netlify Manage panel: the Keys and secrets card highlighted
  5. Name it MAZE_PROXY_URL, tick Contains secret values, keep the Functions scope, paste the URL as the value for the live app and save.
    Netlify project: Manage, Keys and secrets, adding MAZE_PROXY_URL with Contains secret values ticked and the Functions scope
    Netlify now labels this page Keys and secrets (its docs still call it Environment variables).
    You should see: the key in the list with its value hidden.
  6. Install undici (npm install undici) and add a function that uses the helper. A variable set only in netlify.toml is not available to functions at runtime, which is why it goes in the dashboard.
    // netlify/functions/partner-status.mjs
    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),
        },
      });
    }
    
    const dispatcher = proxyAgent(process.env.MAZE_PROXY_URL);
    
    export default async () => {
      const res = await fetch('https://api.example.com/status', {
        dispatcher,
        signal: AbortSignal.timeout(10_000),
      });
      return new Response(await res.text(), { status: res.status });
    };
  7. Trigger a new deploy. Netlify applies changed variables only to new deploys.

Check the IP before you roll out

  1. For a quick check, temporarily point the same function at https://ifconfig.me/ip, deploy a preview and open /.netlify/functions/partner-status on it.
    You should see: your server’s IP, the Host shown in the client area.
  2. Change the URL back, ask the API owner to add that single IPv4, then test the real request.
    You should see: a normal response instead of a 403 or timeout.
  3. Test every path that talks to the API, including scheduled functions, then remove old allowlist entries.

If it still fails

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.

Does Private Connectivity work with Edge Functions? +

No. Netlify says it is not available for Edge Functions. Move the call to a serverless function or a backend with a fixed IP.

Will a function proxy cover calls from the browser? +

No. Only requests made by your server-side code use the proxy. Have the browser call your function, and let the function call the API.

Can I pick the Functions scope only? +

Choosing scopes needs a paid Netlify plan. On the free plan the key gets all scopes, which still includes Functions.

Where should the proxy credentials go? +

In a key marked as a secret, never in client-side code, responses or logs. Give the site its own proxy user so you can rotate it alone.

More guides