【发布时间】:2022-11-09 23:52:53
【问题描述】:
我重新启动了计算机以尝试对其进行更新,并且在重新启动之前,我还在处理另一个项目。现在,我的带有 node.js 后端的项目给了我这个错误:
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:1132:16) {
name: 'MongoNetworkError'
},
roundTripTime: -1,
lastUpdateTime: 58154302,
lastWriteDate: null,
opTime: null,
type: 'Unknown',
topologyVersion: undefined,
minWireVersion: 0,
maxWireVersion: 0,
hosts: [],
passives: [],
arbiters: [],
tags: []
}
},
stale: false,
compatible: true,
compatibilityError: null,
logicalSessionTimeoutMinutes: null,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
commonWireVersion: null
}
我的 mongodb 指南针给了我:connect ECONNREFUSED 127.0.0.1:27017。我的操作系统是 macOS Big Sur。
在另一篇文章中,有人建议重新启动mongod 进程并再次连接。我尝试遵循这些说明mac-mongodb,但是当我转到“从新终端发出以下命令:mongosh”时,我的终端给了我command not found: mongosh。我还尝试使用PATH="/usr/local/opt/mongodb-community@4.4/bin" mongo MongoDB shell version v4.4.13 对其进行测试,但我仍然得到Error: couldn't connect to server 127.0.0.1:27017, 连接被拒绝。
有谁知道如何解决这一问题?我真的很感激任何帮助或建议。谢谢!
【问题讨论】:
-
请确认 mongod 正在运行。如果无法重新启动,单独重新启动将无济于事。如果没有运行 mongod,从终端
mongod --config /usr/local/etc/mongod.conf手动启动它,看看错误是什么。
标签: mongodb econnrefused