Meteor App not able to connect to MongoDB? - mongodb

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.
Below is the error:-
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.

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.
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.
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

I know it's been awhile but I ran into this same issue (in July 13') I didn't have time to figure it out and ended up going to a Linux installation which worked fine.
Recently however I got some time to circle back to it. Here is some discussion on the matter in the google group- https://groups.google.com/forum/#!topic/meteor-talk/AE6GYrJImAo
I found out that the Mongo DB process was not even starting, some conflict within mongo_runner.js ... My solution was to start mongo manually
C:\Program Files (x86)\Meteor\mongodb\bin>mongod -port 3002 --dbpath C:\Users\username\project\.meteor\local\db
The above starts the project on the needed port and specifies the database folder for your project... After this just start meteor as you normally would.

As of Version 0.7.1 the meteor mongodb port is 3001, instead of 3002.
The port is generally 1 higher (2 in the case of older versions of meteor) than the port Meteor is running on. e.g if Meteor runs on port 3000, MongoDB would be at port 3001

Related

MongoDB - configure encryption in cfg file

MongoDB v4 Ent, Windows Server 2016 Std
Starting mongodb from command line works fine:
mongod --enableEncryption --encryptionKeyFile c:\key\mongodb-keyfile
Now I need to change mongod.cfg so windows service starts with encryption enabled. After adding following parameters to file
security:
enableEncryption: true
encryptionKeyFile: c:\key\mongodb-keyfile
service throw error while starting
error 1067: the process terminated unexpectedly
Any ideas?

Failed to start mongod com.Could not find appropriate mongod in `/opt/mongodb/mms/mongodb-releases

I am getting following error when I tried to activate a backup for mongo instance.
I choosed local and copied all rpms to this folder /opt/mongodb/mms/mongodb-releases.
error:
Failed to start mongod
com.xgen.svc.brs.util.GenericMongoManager$MongodVersionException: Could not find appropriate mongod in `/opt/mongodb/mms/mongodb-releases/`, versions available to MMS: . Expecting version 3.4.4 or greater.
com.xgen.svc.brs.util.GenericMongoManager$Purpose.calculateBinaryPath(GenericMongoManager.java:166)
com.xgen.svc.brs.util.GenericMongoManager$Purpose.<init>(GenericMongoManager.java:125)
com.xgen.svc.brs.util.MongoManager$MongoDPurpose.<init>(MongoManager.java:331)
com.xgen.svc.brs.util.MongoManager$HeadPurpose.<init>(MongoManager.java:477)
com.xgen.svc.brs.job.ReplicaSetJob.startMongo(ReplicaSetJob.java:103)
com.xgen.svc.brs.job.ReplicaSetJob.startMongo(ReplicaSetJob.java:80)
com.xgen.svc.brs.job.IncrementalSyncJob.doWork(IncrementalSyncJob.java:82)
com.xgen.svc.brs.grid.Daemon.iterate(Daemon.java:116)
com.xgen.svc.brs.grid.Daemon.run(Daemon.java:305)

How to set up MongoDB to be used with Sublime Text 3

So I have been following this tutorial to set up Sublime Text 3 to use MongoDB. Here's what I did.
I followed this one to install MongoDB and get it up and running.
I opened Sublime Text 3. I clicked Tools > Build System > New Build System. It opened a file named untitled.sublime-build which had the following contents:
{
"shell_cmd": "make"
}
I changed it to
{
"selector":"source.js",
"shell":"true",
"cmd":["C:/Program Files/MongoDB/Server/3.2/bin/mongo", "<", "$file"]
}
Then I saved the file as custom.sublime-build.
Then I opened a new .js file and typed Math.round(Math.random()*100); and built it by Ctrl+B. I got the following errors.
2016-06-21T02:08:11.961+0500 I CONTROL [main] Hotfix KB2731284 or later update is not installed, will zero-out data files
MongoDB shell version: 3.2.7
connecting to: test
2016-06-21T02:08:13.144+0500 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:10061 No connection could be made because the target machine actively refused it.
2016-06-21T02:08:13.187+0500 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
[Finished in 2.4s with exit code 1]
[cmd: ['C:/Program Files/MongoDB/Server/3.2/bin/mongo', '<', 'C:\\xampp\\htdocs\\Tests\\jss.js']]
[dir: C:\xampp\htdocs\Tests]
[path: C:\apache-ant-1.9.7\bin;C:\Program Files\Java\jdk1.8.0_91\bin;C:\Program Files\Java\jdk1.8.0_91\lib;C:\Program Files\Java\jre1.8.0_91\lib;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\git\cmd;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\Git\cmd;C:\Program Files\MongoDB\Server\3.2\bin;]
What should I do to solve this problem and successfully setup Sublime Text 3 to work for MongoDB?
1) Check that you have MongoDB server running that you can connect to. Test by connecting via mongo shell.
2) Change your sublime-build file to escape the Windows path properly.
{
"selector": "source.js",
"shell": true,
"cmd": ["C:\\Program Files\\MongoDB\\Server\\3.2\\bin\\mongo", "<", "$file"]
}
Note the double back-slashes.
3) Make sure the javascript file is saved, so that $file resolved to a path.
for sublime with zip version add your build file to Sublime3XX\Data\Packages\User
folder and restart your sublime text editor u can see your build file in Tools->Build Systems

Error connecting meteor to external mongodb

I have a meteor web app that connects to a mongohq database. It's working correctly on heroku, but I can't get it to work on my localhost. It was working on localhost yesterday, but not today.
To be certain, I just ran a git clone in a new folder. Even this clone is throwing errors on localhost. Here's my terminal (FYI, I'm on a windows 8.1 machine that is running an Ubuntu virtual box; also, I've removed the username / password from the log, below):
adam#adam-VirtualBox:~/resSingleTestV2/faze1tables$ export MONGO_URL=mongodb://<username>:<password>#oceanic.mongohq.com:10033/test_db
adam#adam-VirtualBox:~/resSingleTestV2/faze1tables$ meteor
[[[[[ ~/resSingleTestV2/faze1tables ]]]]]
=> Started proxy.
=> Started your app.
=> App running at: http://localhost:3000/
I20140511-12:53:43.438(-4)? Exception in callback of async function: Error: failed to connect to [oceanic.mongohq.com:10033]
I20140511-12:53:43.637(-4)? at null.<anonymous> (/home/adam/.meteor/packages/mongo-livedata/0120179b5c/npm/node_modules/mongodb/lib/mongodb/connection/server.js:536:74)
I20140511-12:53:43.640(-4)? at EventEmitter.emit (events.js:106:17)
I20140511-12:53:43.641(-4)? at null.<anonymous> (/home/adam/.meteor/packages/mongo-livedata/0120179b5c/npm/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:150:15)
I20140511-12:53:43.641(-4)? at EventEmitter.emit (events.js:98:17)
I20140511-12:53:43.643(-4)? at Socket.<anonymous> (/home/adam/.meteor/packages/mongo-livedata/0120179b5c/npm/node_modules/mongodb/lib/mongodb/connection/connection.js:516:10)
I20140511-12:53:43.643(-4)? at Socket.EventEmitter.emit (events.js:95:17)
I20140511-12:53:43.644(-4)? at net.js:440:14
I20140511-12:53:43.644(-4)? at process._tickCallback (node.js:415:13)
Any help appreciated. Thanks.
I'm connecting via my school's wifi. Turns out they must've done something to prevent me from connecting to mongoHQ because I'm able to connect via other networks.
Strange that it worked for a day or two and then stopped.

mongodb on VMPlayer ubuntu

I have installed mongoDB on ubuntu in VMplayer running on windows7.
I have edited the hosts file to have
machinename 192.168.1.12.
I installed all the packages and trying to start the mongod.
This is the error I am getting:
ubuntu:/etc/init.d$ start mongodb start: Rejected send message, 1
matched rules; type="method_call", sender=":1.128" (uid=1000 pid=9669
comm="start mongodb ") interface="com.ubuntu.Upstart0_6.Job"
member="Start" error name="(unset)" requested_reply="0"
destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
Can you please let me know what could be the issue?
I was able to install successfully in a pevious in ubuntu.
That's a permission error, you need to sudo, i.e. run the following and you will be ok -
sudo start mongodb