MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
at NativeConnection.Connection.openUri (C:\Users\User\stackoverflow-clone\server\node_modules\mongoose\lib\connection.js:847:32)
at C:\Users\User\stackoverflow-clone\server\node_modules\mongoose\lib\index.js:351:10
at C:\Users\User\stackoverflow-clone\server\node_modules\mongoose\lib\helpers\promiseOrCallback.js:32:5
at new Promise ()
at promiseOrCallback (C:\Users\User\stackoverflow-clone\server\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:10)
at Mongoose._promiseOrCallback (C:\Users\User\stackoverflow-clone\server\node_modules\mongoose\lib\index.js:1149:10)
at Mongoose.connect (C:\Users\User\stackoverflow-clone\server\node_modules\mongoose\lib\index.js:350:20)
at connect (C:\Users\User\stackoverflow-clone\server\index.js:6:19)
at Object. (C:\Users\User\stackoverflow-clone\server\index.js:11:3)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
reason: TopologyDescription {
type: 'Single',
setName: null,
maxSetVersion: null,
maxElectionId: null,
servers: Map(1) {
'localhost:27017' => ServerDescription {
address: 'localhost:27017',
error: Error: connect ECONNREFUSED 127.0.0.1:27017
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16) {
name: 'MongoNetworkError'
},
roundTripTime: -1,
lastUpdateTime: 2145741465,
lastWriteDate: null,
opTime: null,
type: 'Unknown',
compatible: true,
compatibilityError: null,
logicalSessionTimeoutMinutes: null,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
commonWireVersion: null
}
}
Asked
Active
Viewed 61 times
-1

firefly_0
- 25
- 4
-
Welcome to Stack Overflow. Right now, the best possible guess anyone can give you is "because there is something wrong in the code and/or data, and this error message explains what the problem is." Please read [ask] and [mre] and ask a specific question that relates to a code example, which you should **show to us**. – Karl Knechtel Apr 01 '23 at 04:52
1 Answers
0
ECONNREFUSED 127.0.0.1:27017 means your application is trying to connect to a local instance of MongoDB that is currently down.
Check If your MongoDB is up and running on port 27017? and are you able to connect using Compass?
If MongoDB is Up & Running - You can try using mongodb connection url from localhost to 127.0.0.1

Basant Mandal
- 96
- 1
- 3