gpt4 book ai didi

javascript - NodeJS Express JS - MongoError : failed to connect to server

转载 作者:行者123 更新时间:2023-12-01 03:52:07 24 4
gpt4 key购买 nike

这个错误是什么意思?

$ pm2 logs
[TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option)
/home/tealou/.pm2/pm2.log last 15 lines:
PM2 | 2017-03-29 07:25:45: App [www] with id [0] and pid [29444], exited with code [1] via signal [SIGINT]
PM2 | 2017-03-29 07:25:45: Starting execution sequence in -fork mode- for app name:www id:0
PM2 | 2017-03-29 07:25:45: App name:www id:0 online
PM2 | 2017-03-29 07:25:46: App [www] with id [0] and pid [29460], exited with code [1] via signal [SIGINT]
PM2 | 2017-03-29 07:25:46: Starting execution sequence in -fork mode- for app name:www id:0
PM2 | 2017-03-29 07:25:46: App name:www id:0 online
PM2 | 2017-03-29 07:25:47: App [www] with id [0] and pid [29477], exited with code [1] via signal [SIGINT]
PM2 | 2017-03-29 07:25:47: Starting execution sequence in -fork mode- for app name:www id:0
PM2 | 2017-03-29 07:25:47: App name:www id:0 online
PM2 | 2017-03-29 07:25:48: App [www] with id [0] and pid [29487], exited with code [1] via signal [SIGINT]
PM2 | 2017-03-29 07:25:48: Starting execution sequence in -fork mode- for app name:www id:0
PM2 | 2017-03-29 07:25:48: App name:www id:0 online
PM2 | 2017-03-29 07:25:49: App [www] with id [0] and pid [29497], exited with code [1] via signal [SIGINT]
PM2 | 2017-03-29 07:25:49: Starting execution sequence in -fork mode- for app name:www id:0
PM2 | 2017-03-29 07:25:49: App name:www id:0 online

/home/tealou/.pm2/logs/www-out-0.log last 15 lines:
0|www | POST /input/XnCuYLP72jGwMt25bPVuuM81uq2 200 233.304 ms - 9
0|www | Successfully connected to mongodb
0|www | POST /input/2psLUE6VB7tEdC0sACCl8Yn1oC6 200 133.400 ms - 9
0|www | Successfully connected to mongodb
0|www | POST /input/2IcNjH69dLyMhrCSi0voaM5OLW8 200 87.776 ms - 9
0|www | Successfully connected to mongodb
0|www | POST /input/lJOVksaP8LMhgOl8XOCofV6ZeZZ 200 117.275 ms - 9
0|www | POST /input/YbJriPtV1FZWUDwgZq46zFqL7BC 200 147.066 ms - 9
0|www | Successfully connected to mongodb
0|www | POST /input/lb8BbtOobixWcfI4dItIaS0U2KZ 200 196.825 ms - 9
0|www | POST /input/97PWLQquQIFxTgpSLZa4rgvXSLR 200 42.662 ms - 9
0|www | POST /input/G4ZrX1Wz88Kx1gcDBN8bw4exi3M 200 127.855 ms - 9
0|www | Successfully connected to mongodb
0|www | POST /input/D2wBHNc4BX19tDkGqXfD8ClY6E0 200 126.571 ms - 9
0|www | Successfully connected to mongodb

/home/tealou/.pm2/logs/www-error-0.log last 15 lines:
0|www | MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
0|www | at .<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/topologies/server.js:327:35)
0|www | at emitOne (events.js:96:13)
0|www | at emit (events.js:188:7)
0|www | at .<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/connection/pool.js:274:12)
0|www | at g (events.js:286:16)
0|www | at emitTwo (events.js:106:13)
0|www | at emit (events.js:191:7)
0|www | at Socket.<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/connection/connection.js:177:49)
0|www | at Socket.g (events.js:286:16)
0|www | at emitOne (events.js:96:13)
0|www | at Socket.emit (events.js:188:7)
0|www | at emitErrorNT (net.js:1272:8)
0|www | at _combinedTickCallback (internal/process/next_tick.js:74:11)
0|www | at process._tickDomainCallback (internal/process/next_tick.js:122:9)

[STREAMING] Now streaming realtime logs for [all] processes
0|www | MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
0|www | at .<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/topologies/server.js:327:35)
0|www | at emitOne (events.js:96:13)
0|www | at emit (events.js:188:7)
0|www | at .<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/connection/pool.js:274:12)
0|www | at g (events.js:286:16)
0|www | at emitTwo (events.js:106:13)
0|www | at emit (events.js:191:7)
0|www | at Socket.<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/connection/connection.js:177:49)
0|www | at Socket.g (events.js:286:16)
0|www | at emitOne (events.js:96:13)
0|www | at Socket.emit (events.js:188:7)
0|www | at emitErrorNT (net.js:1272:8)
0|www | at _combinedTickCallback (internal/process/next_tick.js:74:11)
0|www | at process._tickDomainCallback (internal/process/next_tick.js:122:9)
PM2 | App [www] with id [0] and pid [29513], exited with code [1] via signal [SIGINT]
PM2 | Starting execution sequence in -fork mode- for app name:www id:0
PM2 | App name:www id:0 online
0|www | MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
0|www | at .<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/topologies/server.js:327:35)
0|www | at emitOne (events.js:96:13)
0|www | at emit (events.js:188:7)
0|www | at .<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/connection/pool.js:274:12)
0|www | at g (events.js:286:16)
0|www | at emitTwo (events.js:106:13)
0|www | at emit (events.js:191:7)
0|www | at Socket.<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/connection/connection.js:177:49)
0|www | at Socket.g (events.js:286:16)
0|www | at emitOne (events.js:96:13)
0|www | at Socket.emit (events.js:188:7)
0|www | at emitErrorNT (net.js:1272:8)
0|www | at _combinedTickCallback (internal/process/next_tick.js:74:11)
0|www | at process._tickDomainCallback (internal/process/next_tick.js:122:9)
PM2 | App [www] with id [0] and pid [29527], exited with code [1] via signal [SIGINT]
PM2 | Starting execution sequence in -fork mode- for app name:www id:0
PM2 | App name:www id:0 online
0|www | MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
0|www | at .<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/topologies/server.js:327:35)
0|www | at emitOne (events.js:96:13)
0|www | at emit (events.js:188:7)
0|www | at .<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/connection/pool.js:274:12)
0|www | at g (events.js:286:16)
0|www | at emitTwo (events.js:106:13)
0|www | at emit (events.js:191:7)
0|www | at Socket.<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/connection/connection.js:177:49)
0|www | at Socket.g (events.js:286:16)
0|www | at emitOne (events.js:96:13)
0|www | at Socket.emit (events.js:188:7)
0|www | at emitErrorNT (net.js:1272:8)
0|www | at _combinedTickCallback (internal/process/next_tick.js:74:11)
0|www | at process._tickDomainCallback (internal/process/next_tick.js:122:9)
PM2 | App [www] with id [0] and pid [29544], exited with code [1] via signal [SIGINT]
PM2 | Starting execution sequence in -fork mode- for app name:www id:0
PM2 | App name:www id:0 online
0|www | MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
0|www | at .<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/topologies/server.js:327:35)
0|www | at emitOne (events.js:96:13)
0|www | at emit (events.js:188:7)
0|www | at .<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/connection/pool.js:274:12)
0|www | at g (events.js:286:16)
0|www | at emitTwo (events.js:106:13)
0|www | at emit (events.js:191:7)
0|www | at Socket.<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/connection/connection.js:177:49)
0|www | at Socket.g (events.js:286:16)
0|www | at emitOne (events.js:96:13)
0|www | at Socket.emit (events.js:188:7)
0|www | at emitErrorNT (net.js:1272:8)
0|www | at _combinedTickCallback (internal/process/next_tick.js:74:11)
0|www | at process._tickDomainCallback (internal/process/next_tick.js:122:9)
PM2 | App [www] with id [0] and pid [29554], exited with code [1] via signal [SIGINT]
PM2 | Starting execution sequence in -fork mode- for app name:www id:0
PM2 | App name:www id:0 online
0|www | MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
0|www | at .<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/topologies/server.js:327:35)
0|www | at emitOne (events.js:96:13)
0|www | at emit (events.js:188:7)
0|www | at .<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/connection/pool.js:274:12)
0|www | at g (events.js:286:16)
0|www | at emitTwo (events.js:106:13)
0|www | at emit (events.js:191:7)
0|www | at Socket.<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/connection/connection.js:177:49)
0|www | at Socket.g (events.js:286:16)
0|www | at emitOne (events.js:96:13)
0|www | at Socket.emit (events.js:188:7)
0|www | at emitErrorNT (net.js:1272:8)
0|www | at _combinedTickCallback (internal/process/next_tick.js:74:11)
0|www | at process._tickDomainCallback (internal/process/next_tick.js:122:9)
PM2 | App [www] with id [0] and pid [29564], exited with code [1] via signal [SIGINT]
PM2 | Starting execution sequence in -fork mode- for app name:www id:0
PM2 | App name:www id:0 online

在我的本地主机上一切正常,但在我的生产服务器上却崩溃了。

有什么想法吗?

编辑:

$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 23G 23G 43M 100% /
devtmpfs 7.9G 0 7.9G 0% /dev
tmpfs 7.EDIT:9G 0 7.9G 0% /dev/shm
tmpfs 7.9G 1.5M 7.9G 1% /run
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
tmpfs 1.6G 0 1.6G 0% /run/user/1002

编辑2:

$ mongo
MongoDB shell version: 3.2.6
connecting to: test
2017-03-29T07:21:59.231+0100 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2017-03-29T07:21:59.237+0100 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:229:14
@(connect):1:6

exception: connect failed

编辑3:

$ pm2 logs
[TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option)
/home/tealou/.pm2/pm2.log last 15 lines:
PM2 | 2017-03-29 07:29:48: Time : Wed Mar 29 2017 07:29:48 GMT+0100 (BST)
PM2 | 2017-03-29 07:29:48: PM2 version : 2.4.2
PM2 | 2017-03-29 07:29:48: Node.js version : 6.2.2
PM2 | 2017-03-29 07:29:48: Current arch : x64
PM2 | 2017-03-29 07:29:48: PM2 home : /home/citizensense/.pm2
PM2 | 2017-03-29 07:29:48: PM2 PID file : /home/tealou/.pm2/pm2.pid
PM2 | 2017-03-29 07:29:48: RPC socket file : /home/tealou/.pm2/rpc.sock
PM2 | 2017-03-29 07:29:48: BUS socket file : /home/tealou/.pm2/pub.sock
PM2 | 2017-03-29 07:29:48: Application log path : /home/tealou/.pm2/logs
PM2 | 2017-03-29 07:29:48: Process dump file : /home/tealou/.pm2/dump.pm2
PM2 | 2017-03-29 07:29:48: Concurrent actions : 2
PM2 | 2017-03-29 07:29:48: SIGTERM timeout : 1600
PM2 | 2017-03-29 07:29:48: ===============================================================================
PM2 | 2017-03-29 07:29:49: Starting execution sequence in -fork mode- for app name:www id:0
PM2 | 2017-03-29 07:29:49: App name:www id:0 online

/home/tealou/.pm2/logs/www-error-0.log last 15 lines:
0|www | MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
0|www | at .<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/topologies/server.js:327:35)
0|www | at emitOne (events.js:96:13)
0|www | at emit (events.js:188:7)
0|www | at .<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/connection/pool.js:274:12)
0|www | at g (events.js:286:16)
0|www | at emitTwo (events.js:106:13)
0|www | at emit (events.js:191:7)
0|www | at Socket.<anonymous> (/usr/local/chroot/project-1/node_modules/mongodb-core/lib/connection/connection.js:177:49)
0|www | at Socket.g (events.js:286:16)
0|www | at emitOne (events.js:96:13)
0|www | at Socket.emit (events.js:188:7)
0|www | at emitErrorNT (net.js:1272:8)
0|www | at _combinedTickCallback (internal/process/next_tick.js:74:11)
0|www | at process._tickDomainCallback (internal/process/next_tick.js:122:9)

编辑4:

$ pm2 logs
[PM2] Spawning PM2 daemon with pm2_home=/home/tealou/.pm2

这是什么!?

最佳答案

仅从端口号(27017)(MongoDB 的默认端口)来看,您似乎无法连接到服务器上的 MongoDB。试试installing it并确保它在端口 27017 上运行。

关于javascript - NodeJS Express JS - MongoError : failed to connect to server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43085397/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com