mongo-express 没有连接到 mongodb

Posted

技术标签:

【中文标题】mongo-express 没有连接到 mongodb【英文标题】:mongo-express does not connect to mongodb 【发布时间】:2021-02-22 06:44:11 【问题描述】:

我已经安装了 mongodb 并且可以通过 shell 连接,现在我正在尝试安装 mongo-express,安装成功,我在 config.js 中复制了 config.default.js 文件但它无法连接到蒙哥。从错误中可以看出它无法检索主机名

 (node:3085) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option  useUnifiedTopology: true  to the MongoClient constructor.
(Use `node --trace-deprecation ...` to show where the warning was created)
Could not connect to database at index "0"
(node:3085) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [undefined:27017] on first connect [Error: getaddrinfo ENOTFOUND undefined
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26) 
  name: 'MongoNetworkError'
]
    at Pool.<anonymous> (/Users/name/.config/yarn/global/node_modules/mongodb/lib/core/topologies/server.js:438:11)
    at Pool.emit (events.js:315:20)
    at /Users/name/.config/yarn/global/node_modules/mongodb/lib/core/connection/pool.js:562:14
    at /Users/name/.config/yarn/global/node_modules/mongodb/lib/core/connection/pool.js:995:11
    at /Users/name/.config/yarn/global/node_modules/mongodb/lib/core/connection/connect.js:32:7
    at callback (/Users/name/.config/yarn/global/node_modules/mongodb/lib/core/connection/connect.js:280:5)
    at Socket.<anonymous> (/Users/name/.config/yarn/global/node_modules/mongodb/lib/core/connection/connect.js:310:7)
    at Object.onceWrapper (events.js:422:26)
    at Socket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
(node:3085) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3085) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

【问题讨论】:

【参考方案1】:

我遇到了同样的错误。 强制连接 URL 为我修复了它:

mongo-express --url "mongodb://localhost:27017" --admin

--admin 选项允许列出所有数据库)

【讨论】:

以上是关于mongo-express 没有连接到 mongodb的主要内容,如果未能解决你的问题,请参考以下文章

使用mongo-express管理mongodb数据库

mongo-express远程代码执行(CVE-2019-10758)漏洞复现(msfvenom/wget,反弹shell)

Dockers 部署 MongoDB + mongo-express

云原生之Docker实战使用Docker部署MongoDB数据库管理工具Mongo-Express

应用安全 - 数据库 | 工具 - mongo数据库 - mongo-express - 漏洞 - 汇总

Heroku 没有连接到 Mongo Atlas DB?