If your application can’t connect to MongoDB, the most common cause is an IP whitelist restriction. This guide walks you through diagnosing and fixing MongoDB connection issues.Documentation Index
Fetch the complete documentation index at: https://docs.breezehost.xyz/llms.txt
Use this file to discover all available pages before exploring further.
The Problem: Can’t Connect to MongoDB
You’re seeing errors like:- “Connection timeout”
- “Unable to connect to MongoDB server”
- “Network error”
- “ECONNREFUSED”
- “Authentication failed from IP address”
Why This Happens
MongoDB providers (like MongoDB Atlas) use an IP whitelist for security. Only whitelisted IP addresses can connect to your database. The Challenge with Breeze Hosting: Your Breeze Hosting server’s IP address may change without notice due to infrastructure updates and maintenance. This means a previously working connection might suddenly stop working when our systems assign you a different IP.The Solution: Whitelist 0.0.0.0/0
The most reliable solution is to whitelist the entire range0.0.0.0/0 (all IP addresses) in your MongoDB provider. While this is more permissive, your database credentials still protect your data - only connections with valid credentials can access your database.
How to Whitelist 0.0.0.0/0 in MongoDB Atlas
Follow these steps if you’re using MongoDB Atlas (most common):Log In to MongoDB Atlas
Go to https://www.mongodb.com/cloud/atlas and sign in to your account
Enter IP Range
In the “IP Address / CIDR Block” field, enter:
0.0.0.0/0(This represents all IP addresses)Add Description (Optional)
You can add a description like “Breeze Hosting Servers” to remember why you added this
How to Whitelist 0.0.0.0/0 in Other MongoDB Providers
MongoDB on Self-Hosted/VPS
If you’re hosting MongoDB yourself, check your MongoDB config file:bindIp is set to 0.0.0.0 to allow external connections.
AWS DocumentDB
- Go to the AWS Console
- Navigate to DocumentDB (or RDS if using MongoDB)
- Go to Security Groups or Network Settings
- Add an inbound rule allowing all traffic (0.0.0.0/0) on port 27017
Google Cloud MongoDB
- Go to https://console.cloud.google.com
- Find your MongoDB instance
- Go to “Connections” or “Networking”
- Add a network access entry for 0.0.0.0/0
DigitalOcean Managed Databases
- Go to the DigitalOcean Control Panel
- Click on your MongoDB database
- Go to “Trust” or “Firewalls”
- Add a firewall rule allowing 0.0.0.0/0
Testing Your Connection
After whitelisting the IP range, test your connection:Check Connection String
Get your MongoDB connection string from your providerIt should look like:
mongodb+srv://username:password@cluster0.mongodb.net/dbnameCommand Line Test (if you have MongoDB tools)
Common MongoDB Connection Errors and Fixes
”Authentication failed”
Cause: Incorrect username or password Solution:- Go to MongoDB Atlas > Database Access
- View your database user credentials
- Make sure you’re using the correct username and password in your connection string
- Remember: special characters in passwords need to be URL-encoded (e.g., @ becomes %40)
“Connection timeout”
Cause: Usually IP whitelist issue Solution:- Verify you’ve added the IP whitelist entry for 0.0.0.0/0
- Wait a few minutes for MongoDB to apply network changes
- Check that your connection string is correct
- Verify the Breeze Hosting server has internet access
”MongoNetworkError: connect ECONNREFUSED”
Cause: Server unreachable or connection refused Solution:- Check if MongoDB is actually running
- Verify the host/port in your connection string
- Make sure the IP whitelist allows your server’s IP
- Check if MongoDB provider is experiencing outages at status.mongodb.com
”Access denied to this database”
Cause: Database user doesn’t have permission Solution:- Go to MongoDB Atlas > Database Access
- Edit your database user and grant appropriate roles
- Ensure the user can access the specific database you’re using
Why Not Use a Specific IP Whitelist?
You might wonder: “Why whitelist all IPs instead of just my server’s IP?” Reasons:- IP Changes: Breeze Hosting servers’ IPs may change during maintenance or infrastructure updates
- Multiple Servers: If you have multiple Breeze services, they may have different IPs
- Auto-Scaling: Cloud infrastructure means IPs aren’t static
- No Performance Penalty: Your database credentials still protect your data
Additional Security Measures
If you’re concerned about opening your database to all IPs, consider:Use Strong Credentials
Use Strong Credentials
- Use a long, random password (16+ characters)
- Avoid common password patterns
- Change your password regularly
Limit Database User Permissions
Limit Database User Permissions
- Create a database user with minimal required permissions
- Don’t use admin accounts for applications
- Restrict users to specific databases
Use VPC/Private Network (Advanced)
Use VPC/Private Network (Advanced)
- MongoDB Atlas offers private connectivity options
- DigitalOcean and AWS offer VPC networking
- This is more restrictive but more complex to set up
Enable MongoDB Logs
Enable MongoDB Logs
- Monitor connection attempts and activity
- Set up alerts for suspicious access
- Review logs regularly
Use Connection String Options
Use Connection String Options
- Enable SSL/TLS encryption for data in transit
- Use
retryWrites=truefor reliability - Add
authSource=adminif needed
Still Having Issues?
If whitelisting 0.0.0.0/0 didn’t fix your problem:Verify Basic Connectivity
- Ensure your Breeze service has internet access (can it reach other websites?)
- Confirm MongoDB provider is online
- Test your connection string manually with a MongoDB client
Check Your Connection String
Connection string format:- Wrong password: Special characters must be URL-encoded
- Wrong username: Should be the database user, not your account username
- Missing authSource: May be required depending on setup:
?authSource=admin - Typos in host: Copy exactly from your provider
Application-Specific Issues
If the issue is specific to your application:- Check your application’s documentation for MongoDB setup
- Verify required Node.js/Python packages are installed
- Check application logs for detailed error messages
Contact Support
If you’ve tried everything above:-
Gather information:
- Your MongoDB provider (Atlas, DigitalOcean, etc.)
- Your connection string (with credentials removed)
- The exact error message
- Your Breeze service name
-
Open a support ticket:
- Discord: Join our server and open a ticket
- Email: support@breezehost.xyz
-
We’ll help with:
- Verifying your network configuration
- Checking service connectivity
- Recommending MongoDB provider settings
- Identifying hosting-related issues
Quick Reference
| Issue | Solution |
|---|---|
| Connection timeout | Whitelist 0.0.0.0/0 in MongoDB provider |
| Authentication failed | Check username and password; URL-encode special characters |
| Access denied | Ensure database user has permission for the database |
| Can’t reach server | Verify Breeze service has internet access |
| Connection drops | Whitelist IP range; check provider stability |

