Static IP guide
Connecting to Postgres with a static IP from a Node app on Fly.io
For a Node app on Fly.io reaching a Postgres database that enforces an IP allowlist — outside Fly's private network, where WireGuard cannot help — Fixie Socks provides the fixed source address. The pg driver connects over a socksjs stream, and the database firewall needs only Fixie's two IPs, not whatever egress path a machine has today.
Recommended setup
Use Fixie Socks proxy for Postgres connections to a database that only accepts traffic from approved IP addresses. Store the proxy value in FIXIE_SOCKS_HOST, then configure Node.js to route outbound traffic through Fixie before connecting to Postgres.
Set up Fixie on Fly.io
Create a Fixie Socks proxy in the Fixie dashboard. Copy the proxy value into Fly.io secrets as FIXIE_SOCKS_HOST, and copy the outbound IPs into the destination allowlist.
Set a Fly.io secret
Implementation
The example below shows the core application-side change. Keep credentials in environment variables and avoid committing proxy, database, or API secrets.
Connect to Postgres through FIXIE_SOCKS_HOST
Good to know
- This is for external databases; Fly Postgres reached over the internal private network needs no proxy at all.
- Set
FIXIE_SOCKS_HOSTwithfly secrets setso it is encrypted at rest and injected at boot. - Match the Fixie region to your primary machine region — database round-trips amplify added latency far more than one-off API calls.
Allowlist and test the static IPs
- Open the Fixie dashboard and copy the outbound IP addresses for this proxy.
- Add both IPs to the Postgres firewall or security group.
- Deploy the updated Node.js app on Fly.io.
- Run a small connection test before sending production traffic.
Related guides
- Making API requests with a static IP from a Node app on Fly.io
- Connecting to Postgres with a static IP from a Node app on Heroku
- Connecting to Postgres with a static IP from a Node app on Vercel
- Connecting to Postgres with a static IP from a Node app on Render
- Connecting to Postgres with a static IP from a Node app on AWS Lambda
Related docs
- Node.js implementation examples
- Fly.io setup documentation
- Postgres connection guide
- Fixie-Wrench for TCP forwarding
Is this guide useful?