Cuando me conecto a mi servidor MongoDB Atlas desde un servidor node.js, el siguiente código funciona completamente bien en Heroku:
mongoose.connect(process.env.dbLink, { useNewUrlParser: true, useUnifiedTopology: true }) const db = mongoose.connection db.once("open", () => { console.log("Database connected") })Sin embargo, cuando ejecuto esto en mi computadora, aparece el siguiente error:
const serverSelectionError = new ServerSelectionError(); 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/Sin embargo, mi dirección IP está en la lista blanca.
¿Cómo puedo hacer que esto funcione en mi entorno local?