Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't connect to local (running) mongo using 'meteor mongo'

Tags:

mongodb

meteor

I'm playing with meteor, Installed it on Ubuntu 14.10 & followed the todos tutorial. The Meteor run log:

$ meteor run
[[[[[ ~/bckd/homedir/learn/meteor/mycoolapp ]]]]]

=> Started proxy.                             
=> Started MongoDB.                           
=> Started your app.                          

=> App running at: http://localhost:3000/

When I try to connect to mongo via another terminal, I get:

$ meteor mongo
mongo: Meteor isn't running a local MongoDB server.
This command only works while Meteor is running your application locally. Start your
application first. (This error will also occur if you asked Meteor to use a different MongoDB
server with $MONGO_URL when you ran your application.)

If you're trying to connect to the database of an app you deployed with `meteor deploy`,
specify your site's name with this command.

Trying to work around this problem I looked at the mongo command, and soon enough I figured I can connect using:

$ mongo localhost:3001

So great, that's working and it seems that I am able to use that for the time being.

But... why is the official way: meteor mongo not working in my setup, and can I do anything to fix it?

Edit 5/6/2015

After creating another account on my ubuntu, logging in and creating a new app, I run it and managed to connect to the mongo instance as intended with the meteor mongo command (without sudo). I thought it could be a result of a difference in my environment variables so I compared the two (dumping both environments with the env command. There were some extra bash variables in my primary account so one by one I've unset them until I reached two identical environments (with the exceptions of home directory values, user names, auto-generated values for gnome session tokens and such). Despite those changes, the problem consists. Another wild guess of mine was that the ~/.meteor folder has gone evil on me. So, I've removed it and reinstalled meteor. That didn't fix it either. Whatever the problem is, it's pretty stubborn.

like image 622
tivoni Avatar asked Dec 20 '22 04:12

tivoni


2 Answers

Try:

sudo meteor mongo

it worked for me on a Vagrant box :)

like image 51
David Revelo Avatar answered Feb 16 '23 19:02

David Revelo


  • You need to be the same user as the user who started Meteor.
  • Also you need to connect from within the application directory.
  • Can you connect to the database with the native MongoDB client?
  • Try running sudo meteor mongo - maybe the Meteor/Node process is running as root.
like image 21
Peter Ilfrich Avatar answered Feb 16 '23 20:02

Peter Ilfrich