MongoDB and Mongoose - Create Many Records with model.create()

Tell us what’s happening:
test is getting timed out.

Your project link(s)

require('dotenv').config();
const mongoose=require("mongoose")

mongoose.connect(process.env['MONGO_URI'], { useNewUrlParser: true, useUnifiedTopology: true });

let personSchema = new mongoose.Schema({
  name : {
    type: String,
    required: true
  },
  age :  {
    type: Number
  },
  favoriteFoods : {
      type: [String]
    }
})

let Person = mongoose.model("Person", personSchema);

const createAndSavePerson = function(done) {
  let name1 = new Person({name: "Jack Harry", age: 23, favoriteFoods: ["apple", "eggs" ]});

  name1.save(function(err, data) {
    if (err) return console.error(err);
    console.log(data);
    
    done(null, data)
  });
};

let arrayOfPeople = [
  {name: "Tom", age: 14, favoriteFoods: ["Beans and rice"]},
  {name: "Dick", age: 15, favoriteFoods: ["chicken"]},
  {name: "Harry", age: 34, favoriteFoods: ["pizza"]}
];

const createManyPeople = (arrayOfPeople, done) => {
  Person.create(arrayOfPeople, function (err, people) {
    if (err) return console.log(err);
    done(null, people);
  });
};

const findPeopleByName = (personName, done) => {
  done(null /*, data*/);
};

const findOneByFood = (food, done) => {
  done(null /*, data*/);
};

const findPersonById = (personId, done) => {
  done(null /*, data*/);
};

const findEditThenSave = (personId, done) => {
  const foodToAdd = "hamburger";

  done(null /*, data*/);
};

const findAndUpdate = (personName, done) => {
  const ageToSet = 20;

  done(null /*, data*/);
};

const removeById = (personId, done) => {
  done(null /*, data*/);
};

const removeManyPeople = (done) => {
  const nameToRemove = "Mary";

  done(null /*, data*/);
};

const queryChain = (done) => {
  const foodToSearch = "burrito";

  done(null /*, data*/);
};

/** **Well Done !!**
/* You completed these challenges, let's go celebrate !
 */

//----- **DO NOT EDIT BELOW THIS LINE** ----------------------------------

exports.PersonModel = Person;
exports.createAndSavePerson = createAndSavePerson;
exports.findPeopleByName = findPeopleByName;
exports.findOneByFood = findOneByFood;
exports.findPersonById = findPersonById;
exports.findEditThenSave = findEditThenSave;
exports.findAndUpdate = findAndUpdate;
exports.createManyPeople = createManyPeople;
exports.removeById = removeById;
exports.removeManyPeople = removeManyPeople;
exports.queryChain = queryChain;

solution: boilerplate-mongomongoose - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36

Challenge: MongoDB and Mongoose - Create Many Records with model.create()

Link to the challenge:

The console output is as follows:

 npm start

> fcc-mongo-mongoose-challenges@0.0.1 start
> node server.js

Your app is listening on port 3000
/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:847
  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/
    at NativeConnection.Connection.openUri (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:847:32)
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:351:10
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
    at Mongoose._promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:1149:10)
    at Mongoose.connect (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:350:20)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/myApp.js:4:10)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/server.js:67:16)
    at Module._compile (node:internal/modules/cjs/loader:1105:14) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    setName: null,
    maxSetVersion: null,
    maxElectionId: null,
    servers: Map(3) {
      'ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 1125255,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      },
      'ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 1125029,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      },
      'ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 1125038,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      }
    },
    stale: false,
 npm start

> fcc-mongo-mongoose-challenges@0.0.1 start
> node server.js

Your app is listening on port 3000
OPTIONS
POST
/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:847
  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/
    at NativeConnection.Connection.openUri (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:847:32)
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:351:10
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
    at Mongoose._promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:1149:10)
    at Mongoose.connect (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:350:20)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/myApp.js:4:10)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/server.js:67:16)
    at Module._compile (node:internal/modules/cjs/loader:1105:14) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    setName: null,
    maxSetVersion: null,
    maxElectionId: null,
    servers: Map(3) {
      'ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 1177677,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      },
      'ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 1177271,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      },
      'ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 1177289,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      }
    },
    stale: false,
 npm start

> fcc-mongo-mongoose-challenges@0.0.1 start
> node server.js

Your app is listening on port 3000
/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:847
  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/
    at NativeConnection.Connection.openUri (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:847:32)
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:351:10
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
    at Mongoose._promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:1149:10)
    at Mongoose.connect (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:350:20)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/myApp.js:4:10)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/server.js:67:16)
    at Module._compile (node:internal/modules/cjs/loader:1105:14) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    setName: null,
    maxSetVersion: null,
    maxElectionId: null,
    servers: Map(3) {
      'ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 481728,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      },
      'ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 481722,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      },
      'ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 481825,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      }
    },
    stale: false,
 npm start

> fcc-mongo-mongoose-challenges@0.0.1 start
> node server.js

Your app is listening on port 3000
/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:847
  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/
    at NativeConnection.Connection.openUri (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:847:32)
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:351:10
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
    at Mongoose._promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:1149:10)
    at Mongoose.connect (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:350:20)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/myApp.js:4:10)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/server.js:67:16)
    at Module._compile (node:internal/modules/cjs/loader:1105:14) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    setName: null,
    maxSetVersion: null,
    maxElectionId: null,
    servers: Map(3) {
      'ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 751496,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      },
      'ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 750996,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      },
      'ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 751513,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      }
    },
    stale: false,
 npm start

> fcc-mongo-mongoose-challenges@0.0.1 start
> node server.js

Your app is listening on port 3000
OPTIONS
POST
/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:847
  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/
    at NativeConnection.Connection.openUri (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:847:32)
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:351:10
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
    at Mongoose._promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:1149:10)
    at Mongoose.connect (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:350:20)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/myApp.js:4:10)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/server.js:67:16)
    at Module._compile (node:internal/modules/cjs/loader:1105:14) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    setName: null,
    maxSetVersion: null,
    maxElectionId: null,
    servers: Map(3) {
      'ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 988803,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      },
      'ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 988863,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      },
      'ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 988903,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      }
    },
    stale: false,
 npm start

> fcc-mongo-mongoose-challenges@0.0.1 start
> node server.js

Your app is listening on port 3000
/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:847
  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/
    at NativeConnection.Connection.openUri (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:847:32)
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:351:10
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
    at Mongoose._promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:1149:10)
    at Mongoose.connect (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:350:20)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/myApp.js:4:10)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/server.js:67:16)
    at Module._compile (node:internal/modules/cjs/loader:1105:14) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    setName: null,
    maxSetVersion: null,
    maxElectionId: null,
    servers: Map(3) {
      'ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 1125255,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      },
      'ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 1125029,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      },
      'ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 1125038,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      }
    },
    stale: false,
 npm start

> fcc-mongo-mongoose-challenges@0.0.1 start
> node server.js

Your app is listening on port 3000
OPTIONS
POST
/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:847
  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/
    at NativeConnection.Connection.openUri (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:847:32)
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:351:10
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
    at Mongoose._promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:1149:10)
    at Mongoose.connect (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:350:20)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/myApp.js:4:10)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/server.js:67:16)
    at Module._compile (node:internal/modules/cjs/loader:1105:14) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    setName: null,
    maxSetVersion: null,
    maxElectionId: null,
    servers: Map(3) {
      'ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-00.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 1177677,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      },
      'ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-01.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 1177271,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      },
      'ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net:27017' => ServerDescription {
        address: 'ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net:27017',
        error: Error: getaddrinfo ENOTFOUND ac-cem0m9q-shard-00-02.nggw1hx.mongodb.net
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 1177289,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      }
    },
    stale: false,
 npm start

> fcc-mongo-mongoose-challenges@0.0.1 start
> node server.js

Your app is listening on port 3000




This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.