Проблемы с подключение MongoDB
Код:
const express = require('express');
const mongoose = require('mongoose');
const app = express();
const morgan = require('morgan');
mongoose.set("strictQuery", false);
mongoose.connect('mongodb://localhost:27017/nodetools',
{ useNewUrlParser: true, useUnifiedTopology: true })
.then((result) => console.log('connected to db'))
.catch((err) => console.log(err));
Ошибка:
MongooseServerSelectionError: connect ECONNREFUSED ::1:27017
at Connection.openUri (C:\Users\bymbv\Desktop\clientserv\node_modules\mongoose\lib\connection.js:825:32)
at C:\Users\bymbv\Desktop\clientserv\node_modules\mongoose\lib\index.js:411:10
at C:\Users\bymbv\Desktop\clientserv\node_modules\mongoose\lib\helpers\promiseOrCallback.js:41:5
at new Promise (<anonymous>)
at promiseOrCallback (C:\Users\bymbv\Desktop\clientserv\node_modules\mongoose\lib\helpers\promiseOrCallback.js:40:10)
at Mongoose._promiseOrCallback (C:\Users\bymbv\Desktop\clientserv\node_modules\mongoose\lib\index.js:1285:10)
at Mongoose.connect (C:\Users\bymbv\Desktop\clientserv\node_modules\mongoose\lib\index.js:410:20)
at Object.<anonymous> (C:\Users\bymbv\Desktop\clientserv\app.js:8:10)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) { 'localhost:27017' => [ServerDescription] },
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined
}
Источник: Stack Overflow на русском