MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connection 27 to localhost:27017 timed out]

I’m trying to create some documents using mongoose’s insertMany, but it fails when connecting to Mongo host.

My code is below:

const { current, last } = getDates();
const currentData = await getProofsOfDeliveryData(current);
const lastData = await getProofsOfDeliveryData(last);
const data = [...currentData, ...lastData];
await ProofOfDeliveryProd.deleteMany();
await ProofOfDeliveryProd.insertMany(data);

I expect to insert about 12k documents