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.
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
- Open the Fixie dashboard and copy the outbound IP addresses for this proxy.
- Add both IPs to the MongoDB network access list.
- Deploy the updated Node.js app on Render.
- Run a small connection test before sending production traffic.
Related guides
- Making API requests with a static IP from a Node app on Render
- Connecting to MongoDB with a static IP from a Node app on Heroku
- Connecting to Postgres with a static IP from a Node app on Render
- Connecting to MongoDB with a static IP from a Node app on Vercel