Fah*_*mad 2 mongoose mongodb node.js reactjs server
{ MongoNetworkError: connection 3 to cluster0-shard-00-02-z0urk.mongodb.net:27017 在 TLSSocket 关闭。(/home/fahad/Personal Work/Nodejs/Node js start/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:352:9) 在 Object.onceWrapper (events.js:276:13)在 TLSSocket.emit (events.js:188:13) at _handle.close (net.js:610:12) at TCP.done (_tls_wrap.js:386:7) name: 'MongoNetworkError', errorLabels: [ 'TransientTransactionError ' ],
[Symbol(mongoErrorContextSymbol)]: {} }
module.exports = (app, express , mongoose, path, bodyParser) => {
app.use(express.static(path.resolve(__dirname, "../../dist")));
app.use(bodyParser.json());
mongoose.connect('mongodb+srv://fahad:123@cluster0-z0urk.mongodb.net/test?retryWrites=true', {useNewUrlParser: true})
.then(()=>console.log("DB server connect"))
.catch(e => console.log("DB error", e));
};
Run Code Online (Sandbox Code Playgroud)
当我想连接到https://cloud.mongodb.com时,我遇到了同样的问题 "mongoDB Atlas"这个问题发生在我身上,因为当我构建项目时,我的 IP 存储在安全 -> IP 白名单中。
您将只能从 IP 白名单中的以下 IP 地址列表连接到您的集群。
我设法通过使用 IP 0.0.0.0/0 解决了这个问题,这有助于我从任何地方进行连接。
这对你有帮助吗?
| 归档时间: |
|
| 查看次数: |
2778 次 |
| 最近记录: |