I have followed the good tutorial to connect to a Custom Mongodb: Connecting Auth0 to MongoDB with Custom Databases
When trying to make a connection (to create a first record) I get the very strange error:
“[MongoNetworkError] failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017\n at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16)\n at TCPConnectWrap.callbackTrampoline (internal/async_hooks.js:126:14) {\n name: ‘MongoNetworkError’,\n errorLabels: [Array],\n [Symbol(mongoErrorContextSymbol)]: {}\n}]”
My script works well when used in my own application
const uri = “mongodb+srv://test:XXXXX@customertest.jngaa.mongodb.net/CustomerTest?retryWrites=true&w=majority”;
const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true });
client.connect(function (err) {
if (err) return callback(err);
const db = client.db('xclin');
const users = db.collection('users');
users.findOne({ email: user.email }, function (err, withSameMail) {
Pls help