Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor does not connect to MongoDB

Tags:

mongodb

meteor

I'm trying to connect Meteor to an existing MongoDB. I can't duplicate the database or change its name, because is used by other app.

I know I have to set a MONGO_URL environment var to connect with it. However, after I set it, Meteor is not connecting to the especiefied MongoDB database. I tried doing a .find() but it does not return any docs. An .insert() from the web console shows the info in the page, but it doesn't get inserted in the database. Here are the codes:

$ echo $MONGO_URL
mongodb://localhost:27017/autana_dev

./lib/models.js

Posts = new Meteor.Collection('posts');

./server/app.js

Meteor.publish('posts', function() {
  return Posts.find();
});

./client/app.js

Meteor.subscribe('posts');

Template.main.posts = function() {
  return Posts.find();
};

Any idea? Anyone? My Meteor version release is 0.6.4.1, and the MongoDB version is 2.4.1.

UPDATE: July 28 After running meteor with meteor run, I opened a new console window within project directory to run a meteor mongo console. However, after running meteor mongo I received the following:

mongo: Meteor isn't running.

This command only works while Meteor is running your application
locally. Start your application first.
like image 670
betacar Avatar asked Jul 26 '13 16:07

betacar


1 Answers

As you know, because you posted the issue, this is a bug in meteor.

My workaround was to connect to my mongodb with the standard mongo client. You can find what port your db is running on by looking at the file yourapp/.meteor/db/METEOR-PORT and then just run mongo localhost:[put that port number here] .

like image 120
foobarbecue Avatar answered Nov 09 '22 19:11

foobarbecue