How can local Robo3t connect to a remote Mongo DB instance, but NodeJs fails with IP whitelist error?

I am having issues connecting to MongoDb running remotely, and the connection error response I am getting from the server is somewhat weird.

My network access whitelist is set to allow all ( Hence, my local robo3t installation was able to connect. However, I could not connect from my NodeJs code. Error is: “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”

IP whitelist seems to be an unlikely error, given that my local robo3t client is able to connect remotely to the same remote Mongo Atlas instance, as IP whitelist is allow-all.

How do I debug this kind of thing, please?

try {
	const connectionString =
		process.env.APP_ENV == "test"
			? await getInMemoryMongoDbAdapter()
			: `mongodb://${process.env.MONGODB_HOSTNAME}:${process.env.MONGODB_PORT}/${process.env.CBT_DATABASE_NAME}`;`Connecting to MongoDB service: ${connectionString}`);

	await mongoose.connect(connectionString, {
		useNewUrlParser: true,
		useUnifiedTopology: true,
} catch (error) {

The logger line correctly shows: Connecting to MongoDB service: mongodb://<user>:<password><port>/<database>

My localhost also does not connect via this node app; whereas my robo3t (local MongoDb client) connects. I guess that means Heroku-specific issues can now be comfortably ruled out

Welcome to the MongoDB Community Forums @Damilola_Olowookere!

Since you have already eliminated the IP Access List as a possible issue, I would check on your driver versions and compatibility with your target cluster:

For example, if you are connecting to Atlas Serverless you will need Node.js 4.1 or newer driver.

Can you please provide some further details:

  • version of Mongoose
  • version of MongoDB Node.js driver
  • type of Atlas cluster you are connecting to and the MongoDB server version


Just to make sure. The strings <user>, <password>, <port> and <database> are not really output like that. You edited the real username, password, port and database values so that we do not see them. I asked because it is clear you edited the cluster name to show us xxx.yyy.zzz.