Static IP guide

Connecting to MongoDB with a static IP from a Node app on Render

To keep an Atlas cluster locked to known IPs while your app runs on Render, route Mongoose through Fixie Socks with the driver's built-in proxy options. Render's egress addresses are shared and subject to change; the two Fixie IPs in your Atlas access list are permanent.

RuntimeNode.js and JavaScript
PlatformRender
DestinationMongoDB
Fixie productFixie Socks proxy

Recommended setup

Use Fixie Socks proxy for MongoDB connections from a deployment environment with changing outbound IPs. Store the proxy value in FIXIE_SOCKS_HOST, then configure Node.js to route outbound traffic through Fixie before connecting to MongoDB.

Set up Fixie on Render

Create a Fixie Socks proxy in the Fixie dashboard. Copy the proxy value into Render Environment Variables as FIXIE_SOCKS_HOST, and copy the outbound IPs into the destination allowlist.

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 MongoDB through FIXIE_SOCKS_HOST

const mongoose = require('mongoose');

const fixieValues = process.env.FIXIE_SOCKS_HOST.split(new RegExp('[/(:\\/@)/]+'));

mongoose.connect(process.env.MONGODB_URI, {
  proxyUsername: fixieValues[0],
  proxyPassword: fixieValues[1],
  proxyHost: fixieValues[2],
  proxyPort: Number(fixieValues[3]),
}).then(() => {
  console.log('Connected to MongoDB');
});

Good to know

  • A long-running Render service can keep the Mongoose connection open; the driver's periodic heartbeat traffic doubles as a keepalive through the proxy.
  • Configure both Fixie IPs in Atlas Network Access — a single entry will cause some connection attempts to fail.

Allowlist and test the static IPs

  1. Open the Fixie dashboard and copy the outbound IP addresses for this proxy.
  2. Add both IPs to the MongoDB network access list.
  3. Deploy the updated Node.js app on Render.
  4. Run a small connection test before sending production traffic.

Related guides

Related docs