Meteor App无法连接到MongoDB? [英] Meteor App not able to connect to MongoDB?

查看:72
本文介绍了Meteor App无法连接到MongoDB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Windows上运行流星应用程序.我的机器上运行了本地mongodb,并且在系统上也设置了环境变量<b>MONGO_URL=mongodb://127.0.0.1:27017/sample</b>.流星应用程序仍然无法连接到它.可能是什么问题.

I am trying to run the meteor application on windows. I have local mongodb running on my machine and I have also set the environment variable <b>MONGO_URL=mongodb://127.0.0.1:27017/sample</b> on my system. Still meteor application is not able to connect to it. what could be the issue.

以下是错误:-

C:\workspace\node-workspace\gm>meteor
[[[[[ C:\workspace\node-workspace\gm ]]]]]

=> `Meteor server running on: <b>http://127.0.0.1:3000/</b>`

app/packages/mongo-livedata/mongo_driver.js:113
      throw err;
            ^
Error: failed to connect to [127.0.0.1:3002]
    at Server.connect.connectionPool.on.server._serverState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongo
db\connection\server.js:564:74)
    at EventEmitter.emit (events.js:126:20)
    at connection.on._self._poolState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connecti
on_pool.js:124:15)
    at EventEmitter.emit (events.js:99:17)
    at Socket.errorHandler (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connection.js:465:1
0)
    at Socket.EventEmitter.emit (events.js:96:17)
    at Socket._destroy.self.errorEmitted (net.js:329:14)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)
=> Exited with code: 1
=> Meteor server restarted

app/packages/mongo-livedata/mongo_driver.js:113
      throw err;
            ^
Error: failed to connect to [127.0.0.1:3002]
    at Server.connect.connectionPool.on.server._serverState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongo
db\connection\server.js:564:74)
    at EventEmitter.emit (events.js:126:20)
    at connection.on._self._poolState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connecti
on_pool.js:124:15)
    at EventEmitter.emit (events.js:99:17)
    at Socket.errorHandler (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connection.js:465:1
0)
    at Socket.EventEmitter.emit (events.js:96:17)
    at Socket._destroy.self.errorEmitted (net.js:329:14)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)
=> Exited with code: 1
=> Meteor server restarted

app/packages/mongo-livedata/mongo_driver.js:113
      throw err;
            ^
Error: failed to connect to [127.0.0.1:3002]
    at Server.connect.connectionPool.on.server._serverState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongo
db\connection\server.js:564:74)
    at EventEmitter.emit (events.js:126:20)
    at connection.on._self._poolState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connecti
on_pool.js:124:15)
    at EventEmitter.emit (events.js:99:17)
    at Socket.errorHandler (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connection.js:465:1
0)
    at Socket.EventEmitter.emit (events.js:96:17)
    at Socket._destroy.self.errorEmitted (net.js:329:14)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.

推荐答案

鉴于堆栈跟踪显示流星仍在尝试连接端口3002上的mongoDb实例,则说明您未正确设置环境变量或您尚未重新加载cmd shell以获取新值.

Given that the stack trace says that meteor is still trying to connect to the mongoDb instance on port 3002, then either you have't set the environment variable properly or you haven't reloaded the cmd shell to get the new value.

您如何设置 MONGO_URL ?如果通过系统属性"进行设置或更新了autoexec.bat,则需要重新加载cmd shell.

How did you set MONGO_URL ? If you set it through the System Properties or updated the autoexec.bat then you'll need to re-load the cmd shell.

您可以通过在cmd shell中键入来查看当前值:

You can see what the current value is by typing in the cmd shell:

echo %MONGO_URL%

然后将其设置为当前环境,即可:

Then to set it for the current env you can do :

set MONGO_URL=mongodb://127.0.0.1:27017/sample

这篇关于Meteor App无法连接到MongoDB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆