Why 0.0.0.0/0 is a bad idea
With the whole internet allowed, only the database password protects your data. Leaked connection strings are common (in repositories, logs and screenshots), and automated scanners try Atlas hosts all day.
Your options
- Private endpoints / VPC peering: the strongest option on dedicated clusters, if your app runs in the same cloud.
- Allowlist each developer and server IP: works until an IP changes, then someone is locked out.
- One static IP for everyone: route developers and apps through a dedicated IP and allowlist only that address.
Step 1: get a static IP
Use a server with a fixed IPv4 that only you use. With MazeVPN you get one in about three minutes, with WireGuard for people and a SOCKS5/HTTP proxy for code.
Step 2: add it to Atlas
In Atlas open Security → Network Access → Add IP Address and enter your IP as a single address (it is saved as /32). Remove 0.0.0.0/0 afterwards.
Step 3: developers connect through WireGuard
Turn on the WireGuard tunnel and use Compass or mongosh as usual. Traffic to Atlas leaves from your static IP.
Step 4: apps connect through the SOCKS5 proxy
The official Node.js driver (version 6 and later) can connect through a SOCKS5 proxy, so serverless functions can reach Atlas from your static IP:
import { MongoClient } from 'mongodb';
const client = new MongoClient(process.env.MONGODB_URI, {
proxyHost: process.env.MAZE_IP, // your static IP
proxyPort: 1080, // SOCKS5 port
proxyUsername: 'app',
proxyPassword: process.env.MAZE_PROXY_PASSWORD,
});
await client.connect();Checklist
- Only your static IP (and private endpoints, if any) on the access list.
- Separate database users per app with the least privileges.
- Rotate the proxy password if it leaks; Atlas does not need to change.
Skip the setup
A dedicated server and static IPv4 in 38 cities, ready in about 3 minutes. WireGuard for people, SOCKS5/HTTP proxy for code. From $9.99/month.