- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试创建一个完整的应用程序,阅读以下教程:
https://medium.com/javascript-in-plain-english/full-stack-mongodb-react-node-js-express-js-in-one-simple-app-6cc8ed6de274
我遵循了所有步骤,然后尝试运行:
node server.js
MongoDB connection error: MongoTimeoutError: Server selection timed out after 30000 ms at Timeout._onTimeout (C:\RND\fullstack_app\backend\node_modules\mongodb\lib\core\sdam\server_selection.js:308:9) at listOnTimeout (internal/timers.js:531:17) at processTimers (internal/timers.js:475:7) { name: 'MongoTimeoutError', reason: Error: connect ETIMEDOUT 99.80.11.208:27017 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14) { name: 'MongoNetworkError', [Symbol(mongoErrorContextSymbol)]: {} }, [Symbol(mongoErrorContextSymbol)]: {} } (node:42892) UnhandledPromiseRejectionWarning: MongoTimeoutError: Server selection timed out after 30000 ms at Timeout._onTimeout (C:\RND\fullstack_app\backend\node_modules\mongodb\lib\core\sdam\server_selection.js:308:9) at listOnTimeout (internal/timers.js:531:17) at processTimers (internal/timers.js:475:7)
const mongoose = require('mongoose');
const router = express.Router();
// this is our MongoDB database
const dbRoute =
'mongodb+srv://user:<password>@cluster0-3zrv8.mongodb.net/test?retryWrites=true&w=majority';
mongoose.Promise = global.Promise;
// connects our back end code with the database
mongoose.connect(dbRoute,
{ useNewUrlParser: true,
useUnifiedTopology: true
});
let db = mongoose.connection;
db.once('open', () => console.log('connected to the database'));
最佳答案
只需转到mongodb atlas管理面板。进入安全选项卡>网络访问>然后通过添加IP将其列入白名单
See this image to locate the particular menu
注意:在Google上检查您的IP,然后将其添加
关于node.js - MongoDB连接错误: MongoTimeoutError: Server selection timed out after 30000 ms,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59162342/
我正在尝试创建一个完整的应用程序,阅读以下教程: https://medium.com/javascript-in-plain-english/full-stack-mongodb-react-nod
我正在使用 mongoDB 和 NodeJS 后端。我有问题,问题有 docker 日志如下。 { MongoTimeoutError: Server selection timed out afte
我是一名优秀的程序员,十分优秀!