MongooseServerSelectionError: connect ECONNREFUSED ::1:27017

My Problem:

MongooseServerSelectionError: connect ECONNREFUSED ::1:27017
at Connection.openUri (D:\website\Discord-OAuth2\node_modules\mongoose\lib\connection.js:819:32)
at D:\website\Discord-OAuth2\node_modules\mongoose\lib\index.js:377:10
at D:\website\Discord-OAuth2\node_modules\mongoose\lib\helpers\promiseOrCallback.js:32:5
at new Promise ()
at promiseOrCallback (D:\website\Discord-OAuth2\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:10)
at Mongoose._promiseOrCallback (D:\website\Discord-OAuth2\node_modules\mongoose\lib\index.js:1220:10)
at Mongoose.connect (D:\website\Discord-OAuth2\node_modules\mongoose\lib\index.js:376:20)
at Object. (D:\website\Discord-OAuth2\src\database\database.js:2:27)
at Module._compile (node:internal/modules/cjs/loader:1112:14)
at Module._extensions…js (node:internal/modules/cjs/loader:1166:10) {
reason: TopologyDescription {
type: ‘Unknown’,
servers: Map(1) { ‘localhost:27017’ => [ServerDescription] },
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
logicalSessionTimeoutMinutes: undefined
},
code: undefined
}

My Code:

const mongoose = require(‘mongoose’);
module.exports = mongoose.connect(‘mongodb://localhost:27017/discordauth’,
{ useNewUrlParser: true});

Can someone help me?

means there is no mongod running at the given address. You need to start mongod first.

2 Likes

How I start mongod? with NPM?

Technical writers are better than I to explain, so see

I just noticed that I haven’t installed MongoDB yet. :man_facepalming:

1 Like

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