To fix MongoError: connect ECONNREFUSED 127.0.0.1:27017 error in Node.js, we should check that the connection string is correct.
For instance, we write
const uri = "mongodb://0.0.0.0:27017/";
const client = new MongoClient(uri);
to call MongoClient with the uri connection string to make the connection to MongoDB.