<><>>>说明: 我已经走过以下类似路,并尝试了以下选择:。
- Restarted the MongoDB service.
- Replaced localhost by 0.0.0.0.
- Replaced local host by 127.0.0.1:27017
https://stackoverflow.com/questions/69840504/mongooseserverselectionerror-link-econnrezzed-127017> • 1 27017
www.un.org/Depts/DGACM/index_spanish.htm 如下:。
const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost/db_c");
<<>Nodjs>:>><>>>>>>>>><>strong>v18.13.0<><>>>>
www.un.org/Depts/DGACM/index_spanish.htm 我发现的错误是:。
E:
odejsapp1
ode_modulesmongooselibconnection.js:792
err = new ServerSelectionError();
^
MongooseServerSelectionError: connect ECONNREFUSED ::1:27017
at _handleConnectionErrors (E:
odejsapp1
ode_modulesmongooselibconnection.js:792:11)
at NativeConnection.openUri (E:
odejsapp1
ode_modulesmongooselibconnection.js:767:11) {
reason: TopologyDescription {
type: Unknown ,
servers: Map(1) {
localhost:27017 => ServerDescription {
address: localhost:27017 ,
type: Unknown ,
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 1981963039,
lastWriteDate: 0,
error: MongoNetworkError: connect ECONNREFUSED ::1:27017
at connectionFailureError (E:
odejsapp1
ode_modulesmongodblibcmapconnect.js:370:20) at Socket.<anonymous> (E:
odejsapp1
ode_modulesmongodblibcmapconnect.js:293:22)
at Object.onceWrapper (node:events:628:26)
at Socket.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
cause: Error: connect ECONNREFUSED ::1:27017
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1487:16) {
errno: -4078,
code: ECONNREFUSED ,
syscall: connect ,
address: ::1 ,
port: 27017
},
[Symbol(errorLabels)]: Set(1) { ResetPool }
},
topologyVersion: null,
setName: null,
setVersion: null,
electionId: null,
logicalSessionTimeoutMinutes: null,
primary: null,
me: null,
$clusterTime : null
}
},
stale: false,
compatible: true,
PS E:
odejsapp1> node index.js
E:
odejsapp1
ode_modulesmongooselibconnection.js:792
err = new ServerSelectionError();
^
MongooseServerSelectionError: connect ECONNREFUSED ::1:27017
at _handleConnectionErrors (E:
odejsapp1
ode_modulesmongooselibconnection.js:792:11)
at NativeConnection.openUri (E:
odejsapp1
ode_modulesmongooselibconnection.js:767:11) {
reason: TopologyDescription {
type: Unknown ,
servers: Map(1) {
localhost:27017 => ServerDescription {
address: localhost:27017 ,
type: Unknown ,
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 101790,
lastWriteDate: 0,
error: MongoNetworkError: connect ECONNREFUSED ::1:27017
at connectionFailureError (E:
odejsapp1
ode_modulesmongodblibcmapconnect.js:370:20)
at Socket.<anonymous> (E:
odejsapp1
ode_modulesmongodblibcmapconnect.js:293:22)
at Object.onceWrapper (node:events:628:26)
at Socket.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
cause: Error: connect ECONNREFUSED ::1:27017
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1487:16) {
errno: -4078,
code: ECONNREFUSED ,
syscall: connect ,
address: ::1 ,
port: 27017
},
[Symbol(errorLabels)]: Set(1) { ResetPool }
},
topologyVersion: null,
setName: null,
setVersion: null,
electionId: null,
logicalSessionTimeoutMinutes: null,
primary: null,
me: null,
$clusterTime : null
}
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined
}
PS E:
odejsapp1> node index.js
E:
odejsapp1
ode_modulesmongooselibconnection.js:792
err = new ServerSelectionError();
^
MongooseServerSelectionError: connect ECONNREFUSED ::1:27017
at _handleConnectionErrors (E:
odejsapp1
ode_modulesmongooselibconnection.js:792:11)
at NativeConnection.openUri (E:
odejsapp1
ode_modulesmongooselibconnection.js:767:11) {
reason: TopologyDescription {
type: Unknown ,
servers: Map(1) {
localhost:27017 => ServerDescription {
address: localhost:27017 ,
type: Unknown ,
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 945032,
lastWriteDate: 0,
error: MongoNetworkError: connect ECONNREFUSED ::1:27017
at connectionFailureError (E:
odejsapp1
ode_modulesmongoose
ode_modulesmongodblibcmapconnect.js:370:20)
at Socket.<anonymous> (E:
odejsapp1
ode_modulesmongoose
ode_modulesmongodblibcmapconnect.js:293:22)
at Object.onceWrapper (node:events:628:26)
at Socket.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
cause: Error: connect ECONNREFUSED ::1:27017
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1487:16) {
errno: -4078,
code: ECONNREFUSED ,
syscall: connect ,
address: ::1 ,
port: 27017
},
[Symbol(errorLabels)]: Set(1) { ResetPool }
},
topologyVersion: null,
setName: null,
setVersion: null,
electionId: null,
logicalSessionTimeoutMinutes: null,
primary: null,
me: null,
$clusterTime : null
}
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined
}
我是绝对的开端,寻求你们的帮助。