Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect mongodb clients to local Meteor MongoDB

Tags:

mongodb

meteor

How can I connect Robomongo (or any other mongodb client) to the mongodb instance that is created by my local Meteor application?

like image 856
user3330705 Avatar asked Feb 25 '14 16:02

user3330705


People also ask

How do I connect to a local database in MongoDB?

To connect to your local MongoDB, you set Hostname to localhost and Port to 27017 . These values are the default for all local MongoDB connections (unless you changed them). Press connect, and you should see the databases in your local MongoDB.

Why MongoDB Cannot connect to localhost?

MongoDB failed to connect to 127.0. 0.1(localhost) is the hostname and 27017 is the port number. There could be any reason for this error: Firewall or network configuration blocked you to connect to the server. The MongoDB server is not listening the IP or port.


2 Answers

Ensure Meteor is running on localhost. Open a terminal window and run meteor command. It will start running on localhost:3000 if you have not changed to port.

While it is running, open a separate terminal window and run meteor mongo command. This will open up a MongoDB shell and tell you what port it is connecting to This is normally 3001 as of version 0.7.1.1 or 3002 if earlier. It will say something like 127.0.0.1:3001/meteor

Go to Robomongo (or your favorite mongodb client software) and create a new connection, making sure to change the connection address to localhost and the given the port number. No need to additionally define /meteor if your client does not insist on a default database.

Also as pointed out in https://stackoverflow.com/a/22023284/1064151 some drivers may need specific line endings, delimeters or other character flow. For example, ObjCMongoDB a C based driver wants the url to be 127.0.0.1:3001/ with that extra / at the end, or it won't work. So make sure you check the documentation for your driver/client.

like image 88
Serkan Durusoy Avatar answered Sep 21 '22 15:09

Serkan Durusoy


Easiest way to get the current configuration details is to use the following command

meteor mongo -U 

This will give you the connection string

like image 23
imal hasaranga perera Avatar answered Sep 22 '22 15:09

imal hasaranga perera