连接docker出问题,尝试了多种方法还是不行:MongoDB连接异常
来源:6-12 【实战API】是时候连接MongoDB数据库了

HH2019
2020-03-28
MongoDB连接异常: MongoNetworkError: failed to connect to server [127.0.0.1:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1054:14) {
name: ‘MongoNetworkError’,
[Symbol(mongoErrorContextSymbol)]: {}
3回答
-
李嘉图principal
2023-03-29
mongo-express版本问题,前面用了mongo版本4后面express却默认用最新版本
docker run --link mymongo:mongo p 8081:8081 mongo-express:0.54.0
00 -
HH2019
提问者
2020-04-05
执行的命令为node app.js,股票那个项目,保存信息就是上面的,很长但内容重复,我估计是连不上Docker的mogondb
报错:
henry@MSI:/mnt/c/Users/hxl20/Desktop/Public/mogonDB/PositionService$ node app.js
(node:2374) 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 { useUnified
Topology: true } to the MongoClient constructor.
仓位记录管理服务运行中...
MongoDB连接异常: MongoNetworkError: failed to connect to server [127.0.0.1:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1137:16) {
name: 'MongoNetworkError',
[Symbol(mongoErrorContextSymbol)]: {}
}]
at Pool.<anonymous> (/mnt/c/Users/hxl20/Desktop/Public/mogonDB/PositionService/node_modules/mongodb/lib/core/topologies/server.js:438:11)
at Pool.emit (events.js:311:20)
at /mnt/c/Users/hxl20/Desktop/Public/mogonDB/PositionService/node_modules/mongodb/lib/core/connection/pool.js:561:14
at /mnt/c/Users/hxl20/Desktop/Public/mogonDB/PositionService/node_modules/mongodb/lib/core/connection/pool.js:994:11
at /mnt/c/Users/hxl20/Desktop/Public/mogonDB/PositionService/node_modules/mongodb/lib/core/connection/connect.js:31:7
at callback (/mnt/c/Users/hxl20/Desktop/Public/mogonDB/PositionService/node_modules/mongodb/lib/core/connection/connect.js:264:5)
at Socket.<anonymous> (/mnt/c/Users/hxl20/Desktop/Public/mogonDB/PositionService/node_modules/mongodb/lib/core/connection/connect.js:294:7)
at Object.onceWrapper (events.js:418:26)
at Socket.emit (events.js:311:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
name: 'MongoNetworkError',
[Symbol(mongoErrorContextSymbol)]: {}
}
(node:2374) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [127.0.0.1:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1137:16) {
name: 'MongoNetworkError',
[Symbol(mongoErrorContextSymbol)]: {}
}]
at Pool.<anonymous> (/mnt/c/Users/hxl20/Desktop/Public/mogonDB/PositionService/node_modules/mongodb/lib/core/topologies/server.js:438:11)
at Pool.emit (events.js:311:20)
at /mnt/c/Users/hxl20/Desktop/Public/mogonDB/PositionService/node_modules/mongodb/lib/core/connection/pool.js:561:14
at /mnt/c/Users/hxl20/Desktop/Public/mogonDB/PositionService/node_modules/mongodb/lib/core/connection/pool.js:994:11
at /mnt/c/Users/hxl20/Desktop/Public/mogonDB/PositionService/node_modules/mongodb/lib/core/connection/connect.js:31:7
at callback (/mnt/c/Users/hxl20/Desktop/Public/mogonDB/PositionService/node_modules/mongodb/lib/core/connection/connect.js:264:5)
at Socket.<anonymous> (/mnt/c/Users/hxl20/Desktop/Public/mogonDB/PositionService/node_modules/mongodb/lib/core/connection/connect.js:294:7)
at Object.onceWrapper (events.js:418:26)
at Socket.emit (events.js:311:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:2374) 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 handle
d 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:2374) [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.
012020-04-12 -
Stannum
2020-04-04
同学好~可不可以把你执行的命令和完整的错误信息也发出来看一下?
00
相似问题