Could not connect to the servers in your MongoDB Atlas cluster

Encounter this error when trying to connect to the cluster on mongoDB atlas.
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://docs.atlas.mongodb.com/security-whitelist/

I have whitelisted my IP and I have tried every possible methods I found on the internet, they just don’t work.

const mongoose = require("mongoose");

const port = process.env.PORT || 5000;

const connectionParams = {
    useNewUrlParser: true,
    useCreateIndex: true,
    useUnifiedTopology: true 
}

mongoose
     .connect(process.env.ATLAS_URL, connectionParams)
     .then(() => console.log( 'Database Connected' ))
     .catch(err => console.log( err ));

i have also tried every possible way from the internet, the only solution that works to me is to change internet connection to any other bandwidth like mobile hotspot

Me too, I think for me the comoany’s wifi that I was using has firewall blocking the connections so as soon as I changed to a personal hotspot, I was in, connected.