我尝试从NodeJS App连接到MongoDB。
连接正在我的本地计算机上运行,所以它必须是我的OpenShift的问题。
在我的服务器代码中,我使用:
mongoose.connect(process.env.OPENSHIFT_MONGODB_DB_URL)
但是我在日志中遇到以下错误:
DEBUG: Starting child process with 'node server/server.js'
Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
Express server listening on port 8080
/var/lib/openshift/57a1ec260c1e662f1c00009f/app-root/runtime/repo/node_modules/mongoose/node_modules/mongodb/lib/server.js:261
process.nextTick(function() { throw err; })
^
MongoError: failed to connect to sDerver [localhost:27017] on first connect
at null.<anonymous> (/var/lib/openshift/57a1ec260c1e662f1c00009f/app-root/runtime/repo/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:313:35)
at emit (events.js:95:17)
at null.<anonymous> (/var/lib/openshift/57a1ec260c1e662f1c00009f/app-root/runtime/repo/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:271:12)
at g (events.js:180:16)
at emit (events.js:98:17)
at Socket.<anonymous> (/var/lib/openshift/57a1ec260c1e662f1c00009f/app-root/runtime/repo/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:165:49)
at Socket.g (events.js:180:16)
at Socket.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:442:13)
DEBUG: Program node server/server.js exited with code 8