How to identify the port of minimongo running inside meteor? - mongodb

I am novice in meteor. I was developing an application which leverages the mongo db which comes with the meteor package. The meteor is running under the port 3000, but i want to know under what port the mini mongo runs. I am using a tool MongoVUE to view all the collections that is under mongo running in a port. I was able to view the mongo collections when i run the standalone mongo since i know the port for that but for this mini mongo running under meteor i am not able to know the port. Any help is appreciated.

Mingomongo runs in the browser, it's a client-side Javascript library.. it runs in memory, it doesn't have a port.. it enables you to query data published by the server in your client application, using MongoAPI style syntax..
to get the connection string of the Mongo instance running on the server (say, if you want to connect from a different client, or just see the port number) run
meteor mongo -U

Using ps auxww|grep mongo|grep meteor on my Fedora system I get:
jwulf 20635 0.3 2.6 150800 41336 pts/1 Sl+ 17:07 0:01 /usr/lib/meteor/mongodb/bin/mongod --bind_ip 127.0.0.1 --smallfiles --port 3002 --dbpath /home/jwulf/tools/leaderboard/.meteor/local/db
So it is running on port 3002 on my system. Starting mongo with --port 3002 allows me to connect to the Meteor mongo server and copy data into the database.
You can also connect to the local instance by running meteor mongo in your Meteor app directory.
The database itself is at <app-name>/.meteor/local/db on my Fedora system.

In meteor 0.8.3 it's using port 3001
so I run:
mongo localhost:3001
use use meteor
and I'm good to go...thanks to Sitapati Das for the command above...

Related

Connect mongo with meteor in production

I have deployed my meteor application on localhost for demo purpose by following what was mentioned here.
$export MONGO_URL='mongodb://localhost'
$ export PORT=3000
$ export ROOT_URL='http://example.com'
$ node main.js
I have had a bunch of collections in my meteor's mongo instance while development and need to move it to the new db that the deployed version connects to. I've taken a mongo dump of that and I know how to restore it. My question is, how exactly do I connect to the mongo db in order to do this?
I've tried:
mongo localhost
mongo localhost:3000
mongo -U localhost
They don't seem to work.
NOTE -
I do not want to run the mongo in development environment using meteor mongo. I have to deploy this in the client machine.
You can use the Meteor command line tools to attach to your local meteor instance.
meteor mongo
Taken from https://docs.meteor.com/commandline.html#meteormongo
Also, I think your commands didn't work 'cause the meteor mongo instance is hosted on port 3001 instead of 3000. Port 3000 hosts the actual meteor app, 3001 is the mongo instance.
As k.chao.0424 says you can use meteor mongo to connect to the mongo db via terminal or command line if you are using windows. But as i see you used the port 3000 for mongodb. I suggest you a simple way you just run the follwing command to run meteor and mongo db just write on your terminal:-
meteor
or if you are using ubuntu and any permission issues than write:-
sudo meteor
It will automatically run your project on 3000 port and your mongdb in 3001 port as by default after running app you can connect with mongodb via following command:-
meteor mongo
Hope this will help!

Connect mongodb server via robomongo from another PC

I am using mongodb database for my meteor app. I want to access it from another pc. I have mounted my local as a virtual drive on other PC using ssh. Now I want to connect to mongodb via robomongo. I have given the address as 192.168.1.2:4001 (ip addr of local : port on which meteor is running +1). But its giving an error 'Unable to connect to mongodb'. How to proceed?
The other way around is to start your meteor on a regular mongo server with this command :
MONGO_URL=mongodb://localhost:27017/nameOfDatabase meteor
Be sure to have a running mongo on localhost and to change the nameOfDatabase.
Now it's just a regular mongoDB server to connect. Also you might need to add login and password to that mongo url and the debug parameter after meteor if you use packages like meteor toys.
Please check mongodb's config file /etc/mongod.conf and comment out bind ip
net:
#bindIp: 127.0.0.1
port: 4001
Restart mongodb service. This will allow mongodb to bind to ip's other than localhost.

How to connect to a remote meteor mongodb using robomongo

I am using Meteor. Which is installed on another server.
I want to access its mongodb from another [Ubuntu Machine].
Now how can I access that mongodb via robomongo or any other tool?
Any guidance or help would be appreciated.
In Robomongo in the upper left:
Click create
In the pop-up window enter the address and port of your Mongo server
Give the connection a name and click save.
Using the Terminal (on the client):
mongo --host <hostname> --port <port>
You have to make sure the port is not blocked on the Ubuntu machine running the Meteor application. Note: when developing a Meteor app the default Mongo port is 3001.

How to connect mongodb clients to local Meteor MongoDB

How can I connect Robomongo (or any other mongodb client) to the mongodb instance that is created by my local Meteor application?
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.
Easiest way to get the current configuration details is to use the following command
meteor mongo -U
This will give you the connection string
From terminal run following command
meteor mongo -U
That will show you the local host IP address and in which port you application is running. Now run the Robomongo and configure as following two field as you got by running the previous command
Use SSH tunneling by the following command :
ssh -L 3001:localhost:3001 user-name#host
It forwards connections from your local port 3001 to localhost:3001 on your server. Now we can simply connect to our database.
Create a Robomongo connection on your localhost and hit Test (Out of two checks, Authentication may fail) :
I'm using ObjCMongoDB, a C based mongoDB driver. With the new update instead of using the previous 127.0.0.1:3002 to connect to my localhost running meteor's mongodb, I now need to use 127.0.0.1:3001/ with the collection name still being meteor.collection. The important change is the port from :3002 to :3001/. Remember the /, it is critical for the connection.
This worked for me,Before connecting make sure meteor is running.
I am using Robomongo to connect. Create new connection and add
Address as : localhost;
port as: 3001
I'm too using Robomongo and before the latest update V0.7.1,i used port 3002 to connect,as #Serkan Durusoy suggest's for the latest update it is working for 3001 port
#imal365 answer is perfect. Just to add my insight on it:
I realized that the default Meteor Mongo port number is the port number of the application with 1 added to it (as of version 0.7.1.1). In my case, I was running Meteor on port 1337 with the command meteor --port 1337 and my Meteor Mongo port was 1338.

Cannot connect to mongod running in Ubuntu machine

I would like to connect with mongo from a cmd shell in windows to a mongod database running in a Ubuntu virtual machine.
mongo is running fine in the Ubuntu terminal and from a putty shell
When I use mongo from a windows cmd shell, I got this error:
mongo.exe --host 192.168.1.6 --port 27017
MongoDB shell version: 2.4.6
connecting to: 192.168.1.6:27017/test
Sat Feb 01 14:45:32.181 Error: couldn't connect to server 192.168.1.6:27017 at src/mongo/shell/mongo.js:147
exception: connect failed
What should I do to be able to connect?
My goal is to use MongoVue to connect to the mongod database in the Ubuntu machine (by the way, MongoVue is not connecting even using its SSH options).
I am trying to connect to the mongod instance of a meteorjs application.
The meteor application is up and running and I can connect to the mongod instance running on the Ubuntu machine at port 3002, both in the Ubuntu terminal and with a putty shell.
stefano#MeteorDeploy:~$ mongo --port 3002
MongoDB shell version: 2.0.4
connecting to: 127.0.0.1:3002/test
PRIMARY> show dbs
local 0.0625GB
meteor 0.0625GB
I would like to connect to the mongod instance using MongoVue as alternative of the putty shell.
I did as in the docs.mongodb.org/manual/tutorial/configure-linux-iptables-firewall/ but without success.
Meteor runs it's own instance of mongo per app. As you note since your edit, when you ssh into your VM you use --port 3002 to connect.
Now you could add that port to your mongo shell launch except for one problem
ps -ef | grep mongo
on your VM will show you the running instance of mongo along with it's startup options. By default this will be bound to 127.0.0.1 which is the loopback adaptor and not accessible outside of the VM.
So what you need to do is either change the startup options in your project, or use another instance on mongo installed on the local machine.
export MONGO_URL=mongodb://localhost:27017/your_db
By default mongod insllation on Ubuntu only listen to localhost, so you can't connect from Windows.
Edit /etc/mongodb.conf and change the bind_ip line (add your windows IP adress on the local network) so it will accept connection.
Be aware that by default mongod does not require authentification so you would maybe want to settup one.
Doc is here :
http://docs.mongodb.org/manual/reference/configuration-options/#bind_ip
For quick and dirty solution (not for Production):
Edit /etc/mongodb.conf and change the bind_ip to 0.0.0.0