Skip to main content

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.

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.

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”
These errors typically mean MongoDB is blocking your server’s 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 range 0.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.
Only whitelist 0.0.0.0/0 if your MongoDB instance requires a whitelist. For production databases with sensitive data, consider additional security measures like VPCs or network isolation.

How to Whitelist 0.0.0.0/0 in MongoDB Atlas

Follow these steps if you’re using MongoDB Atlas (most common):
1

Log In to MongoDB Atlas

Go to https://www.mongodb.com/cloud/atlas and sign in to your account
2

Select Your Project

Click on your project from the dashboard
3

Go to Network Access

In the left sidebar, find “Network Access” under “Security”
4

Click Add IP Address

Click the “Add IP Address” or ”+ Add IP Whitelist Entry” button
5

Enter IP Range

In the “IP Address / CIDR Block” field, enter: 0.0.0.0/0(This represents all IP addresses)
6

Add Description (Optional)

You can add a description like “Breeze Hosting Servers” to remember why you added this
7

Confirm

Click “Add IP Address” to save the whitelist entry
8

Wait for Changes

MongoDB Atlas will take 1-2 minutes to apply the network access change
9

Test Connection

Try connecting to your database from your Breeze Hosting service. The connection should now work.

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:
net:
  bindIp: 0.0.0.0
  port: 27017
Ensure bindIp is set to 0.0.0.0 to allow external connections.

AWS DocumentDB

  1. Go to the AWS Console
  2. Navigate to DocumentDB (or RDS if using MongoDB)
  3. Go to Security Groups or Network Settings
  4. Add an inbound rule allowing all traffic (0.0.0.0/0) on port 27017

Google Cloud MongoDB

  1. Go to https://console.cloud.google.com
  2. Find your MongoDB instance
  3. Go to “Connections” or “Networking”
  4. Add a network access entry for 0.0.0.0/0

DigitalOcean Managed Databases

  1. Go to the DigitalOcean Control Panel
  2. Click on your MongoDB database
  3. Go to “Trust” or “Firewalls”
  4. Add a firewall rule allowing 0.0.0.0/0

Testing Your Connection

After whitelisting the IP range, test your connection:
1

Check Connection String

Get your MongoDB connection string from your providerIt should look like: mongodb+srv://username:password@cluster0.mongodb.net/dbname
2

Test in Your Application

Try connecting from your Breeze Hosting service
3

Check Logs

If it still doesn’t work, check your application logs for the specific error
4

Verify Credentials

Make sure your username and password are correct

Command Line Test (if you have MongoDB tools)

mongosh "mongodb+srv://username:password@cluster0.mongodb.net/dbname"

Common MongoDB Connection Errors and Fixes

”Authentication failed”

Cause: Incorrect username or password Solution:
  1. Go to MongoDB Atlas > Database Access
  2. View your database user credentials
  3. Make sure you’re using the correct username and password in your connection string
  4. Remember: special characters in passwords need to be URL-encoded (e.g., @ becomes %40)

“Connection timeout”

Cause: Usually IP whitelist issue Solution:
  1. Verify you’ve added the IP whitelist entry for 0.0.0.0/0
  2. Wait a few minutes for MongoDB to apply network changes
  3. Check that your connection string is correct
  4. Verify the Breeze Hosting server has internet access

”MongoNetworkError: connect ECONNREFUSED”

Cause: Server unreachable or connection refused Solution:
  1. Check if MongoDB is actually running
  2. Verify the host/port in your connection string
  3. Make sure the IP whitelist allows your server’s IP
  4. Check if MongoDB provider is experiencing outages at status.mongodb.com

”Access denied to this database”

Cause: Database user doesn’t have permission Solution:
  1. Go to MongoDB Atlas > Database Access
  2. Edit your database user and grant appropriate roles
  3. 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:
  1. IP Changes: Breeze Hosting servers’ IPs may change during maintenance or infrastructure updates
  2. Multiple Servers: If you have multiple Breeze services, they may have different IPs
  3. Auto-Scaling: Cloud infrastructure means IPs aren’t static
  4. No Performance Penalty: Your database credentials still protect your data
Security Note: Anyone could attempt to connect to your database, but without valid credentials, they cannot access it. Think of it like a house - anyone can knock on your door, but only those with a key can enter.

Additional Security Measures

If you’re concerned about opening your database to all IPs, consider:
  • Use a long, random password (16+ characters)
  • Avoid common password patterns
  • Change your password regularly
  • Create a database user with minimal required permissions
  • Don’t use admin accounts for applications
  • Restrict users to specific databases
  • MongoDB Atlas offers private connectivity options
  • DigitalOcean and AWS offer VPC networking
  • This is more restrictive but more complex to set up
  • Monitor connection attempts and activity
  • Set up alerts for suspicious access
  • Review logs regularly
  • Enable SSL/TLS encryption for data in transit
  • Use retryWrites=true for reliability
  • Add authSource=admin if needed

Still Having Issues?

If whitelisting 0.0.0.0/0 didn’t fix your problem:

Verify Basic Connectivity

  1. Ensure your Breeze service has internet access (can it reach other websites?)
  2. Confirm MongoDB provider is online
  3. Test your connection string manually with a MongoDB client

Check Your Connection String

Connection string format:
mongodb+srv://username:password@host/database?retryWrites=true&w=majority
Common mistakes:
  • 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
Note: For application-specific coding issues, see our FAQ.

Contact Support

If you’ve tried everything above:
  1. Gather information:
    • Your MongoDB provider (Atlas, DigitalOcean, etc.)
    • Your connection string (with credentials removed)
    • The exact error message
    • Your Breeze service name
  2. Open a support ticket:
  3. We’ll help with:
    • Verifying your network configuration
    • Checking service connectivity
    • Recommending MongoDB provider settings
    • Identifying hosting-related issues

Quick Reference

IssueSolution
Connection timeoutWhitelist 0.0.0.0/0 in MongoDB provider
Authentication failedCheck username and password; URL-encode special characters
Access deniedEnsure database user has permission for the database
Can’t reach serverVerify Breeze service has internet access
Connection dropsWhitelist IP range; check provider stability

External Resources