MongoError:没有可用的主服务器

7 mongodb node.js express node-modules mongodb-atlas

我正在 node.js 中使用 express 和 mongodb 运行一个简单的restful api,但出现此错误:

{ MongoError: no primary server available
at ReplSetState.pickServer (/Users/Computer/Desktop/Username/node_modules/mongodb/lib/core/topologies/replset_state.js:780:12)
at Timeout._selectServer [as _onTimeout] (/Users/Computer/Desktop/Username/node_modules/mongodb/lib/core/topologies/replset.js:1147:43)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10) name: 'MongoError', [Symbol(mongoErrorContextSymbol)]: {} }
Run Code Online (Sandbox Code Playgroud)

这已经发布了,但回复对我没有帮助

小智 0

我有同样的问题,因为我忘记在 mongoDB 上将我的 IP 列入白名单。尝试这样做