← Guides

How to get a static outbound IP on Railway

A database or partner API only accepts known IPs, and your Railway service keeps getting rejected. Railway has a built-in fix on the Pro plan. Here is how to turn it on, where it falls short, and when a proxy is the better fit.

Updated 2026-11-23 · 7 min read

Why your Railway service gets blocked

By default a Railway service has no fixed outbound address, so a firewall that only accepts known IPs has nothing stable to allow. You see timeouts or refused connections from a database, or 403 errors from a partner API, even though your credentials are correct.

Before you change anything, ask the owner of the database or API to check their firewall log for your rejected connection, and whether they accept several addresses or only one.

Option 1: Railway Static Outbound IPs (Pro)

  1. Open the service, go to the Settings tab and find Networking. Turn on Enable Static IPs.
    You should see: the IPv4 addresses for the service’s region. Services with the current setup get three addresses with traffic balanced across them.
  2. Redeploy the service. Outbound traffic only uses the new addresses after a deploy. The CLI does the same: railway outbound-network static-ip enable --service api, then redeploy.
  3. Allowlist every address Railway shows, not just the first one.
Don’t see Enable Static IPs? It is a Pro feature. We checked on a trial account: the Networking section shows only public and private networking and outbound IPv6, without the static IP switch (screenshot below).
Railway service Settings, Networking section on a trial account: no Enable Static IPs switch
Trial account: Networking shows public and private networking and outbound IPv6, but no static IP switch (Pro only).

What to know before you rely on it

Option 2: send selected requests through a dedicated IP

If the partner needs an address only you use, or you are not on Pro, route just the requests that need allowlisting through your own server. Everything else keeps going out directly.

Request route through your static IP Railway service 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 railway and click Add.
    MazeVPN client area: Add a proxy user, with the name railway typed in
    You should see: a new card named app-railway. 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-railway:…@203.0.113.42:443, where the address is your server’s IP.
  3. In Railway, open the project and click the service on the canvas.
    Railway project canvas with the service highlighted
  4. Open the Variables tab and click New Variable. Enter MAZE_PROXY_URL, paste the URL and click Add.
    Railway service Variables tab: New Variable with the name MAZE_PROXY_URL
    Railway stages the change; click Deploy at the top of the canvas to apply it.
  5. Click Deploy in the bar at the top left of the canvas (Apply 1 change). Railway stages variable changes until you deploy them.
    Railway: the variable is staged, with Apply 1 change and the Deploy button highlighted
    You should see: a new deployment starting under Deployments.
  6. Pass a proxy dispatcher only to the calls that need the fixed IP (npm install undici):
    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 async function getPartnerOrders() {
      const res = await fetch('https://api.example.com/v1/orders', {
        dispatcher,
        signal: AbortSignal.timeout(10_000),
      });
      if (!res.ok) throw new Error('Partner API: ' + res.status);
      return res.json();
    }

Test it before you change the allowlist

  1. From the deployed service, call https://ifconfig.me/ip (directly with static IPs on, or through the same dispatcher with a proxy) and log the result once.
    You should see: one of the addresses from Railway’s settings, or your server’s IP.
  2. Run one real read-only request against the partner or database. Keep the old allowlist entries until it works.

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 Railway give me a dedicated IP? +

Not guaranteed. Railway’s static outbound IPs are permanent for the service and region, but they may be shared with other customers.

Do I need to redeploy after enabling static IPs? +

Yes. Outbound traffic only uses the new addresses after the service is redeployed.

Does the static IP cover database connections? +

Railway’s static IPs apply to all outbound traffic of the service, so database connections use them too. An HTTP proxy only covers HTTP requests made through it.

What does a dedicated IP from MazeVPN cost? +

Solo is $9.99 a month with one dedicated IPv4 and three proxy users. Some cities cost extra. See the pricing page.

More guides