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)
- 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.
- 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. - Allowlist every address Railway shows, not just the first one.
What to know before you rely on it
- The addresses may be shared. Railway says there is no guarantee they are dedicated to you, so keep your database password, API keys and TLS in place.
- Moving the service to another region changes the addresses. Plan allowlist updates before a region move.
- They are outbound only. You cannot use them to receive traffic.
- Static IPs can stop App Sleep from putting an idle service to sleep, which can raise your usage bill.
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.
- 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
railwayand click Add.
You should see: a new card namedapp-railway. Names can use letters and digits only, and MazeVPN adds theapp-prefix. - 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.
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 likehttps://app-railway:…@203.0.113.42:443, where the address is your server’s IP. - In Railway, open the project and click the service on the canvas.
- Open the Variables tab and click New Variable. Enter
MAZE_PROXY_URL, paste the URL and click Add.
Railway stages the change; click Deploy at the top of the canvas to apply it. - Click Deploy in the bar at the top left of the canvas (Apply 1 change). Railway stages variable changes until you deploy them.
You should see: a new deployment starting under Deployments. - 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
- 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. - 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.