Can't connect to mongodb (IPs already whitelisted)

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:

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, 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.

1 Like