2 / 5
Feb 21

Hello !

I can’t connect my server to Mongo (in production only), it perfectly works in local development (using docker)

I tried mongo compass to connect to the cluster and it works well too.

The mongoose error is this one: MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you’re trying to access the database from an IP that isn’t whitelisted. Make sure your current IP address is on your Atlas cluster’s IP whitelist: https://www.mongodb.com/docs/atlas/security-whitelist/

I already checked the connection string multiple times, it didn’t change (because I am testing the free version)

I have checked the IPs address allowed (in network access), I added my IP manually, my server IP, an other IP from my server (defined as front IP address in cpanel) and I added the famous 0.0.0.0, address to allow all access.

I tried to “await mongoose.connect” in the app code then listen to my server app.

But no result… still can connect only from the o2switch server

I am using express as server and my server host is o2switch (with Cpanel)

Hope it 's clear enought :slight_smile:

I appreciate any helps ! Thx per advance.

12 months later

Hello,

Sorry didn’t find a fix to this issue.
My “fix” was to switch to an other server that allow trafic between the server and mongodb.

I could configure in the cpanel, even with the o2switch support service.