Meteor with external MongoDB

Meteor with external MongoDB

As described in my previous post, I needed to use a custom MongoDB installation on my server since I could not access the Meteor MongoDB from an external server. Here is how I setup Meteor to work with this database.


I stumbled on this post on StackOverflow. It turned out you can the environment variable MONGO_URL which you could point to your MongoDB installation.

export MONGO_URL='mongodb://user:[email protected]:12345/'

You can check if the variable was correctly set by:


If you want to go back to the default behaviour where Meteor uses its own MongoDB. You need to unset the MONGO_URL environment variable


Using this I made a stupid mistake. I used two terminals one to run Meteor and one to check the database. When you have two terminals and you set an environment variable in one of them you need to restart the other one to see the newly set variable. I forgot about this and it took some time to figure out why this wasn’t working.

Now I start my project with this command:

MONGO_URL='mongodb://user:[email protected]:12345/' meteor

When you view your database after the first run you see nothing there yet. I was looking for the meteor database to be there, but it wasn’t. Meteor does not create this database if there is no data to write yet. Therefore you need to write some data to a collection to see if Meteor is connecting to the right MongoDB.

In order to check the content of the MongoDB I started the mongo command which connected me to the running MongoDB instance with just running:

$ mongo

Then I needed to select the meteor database:

use meteor

Check which collections are in the meteor database:

show collections

Check the contents of the meteor collection


5 thoughts on “Meteor with external MongoDB

  1. wow – UNSET MONGO_URL to return to normal meteor operation!
    I made the same mistake you did and for a week I was going in circles. Thank you VERY much for pointing me in the right direction!!!!! Without your very apropos pointer no telling when I’d surface. I was about to go down the remote DB route.

    thanks again

  2. If on any Linux distribution, I would just set the environment variable in the following file and restart all terminals (or use reset commands) instead of messing with EXPORT command. Any issues with this?
    $tail /etc/environment

  3. the one which you made here is for linux, I’m using windows and trying to get the same type of tutorial in web. But unfortunately i’m not getting anything like this. If you can share how to do the same in windows it would be helpful.

  4. I was wondering for a while why the collection comes empty. You were right, until I inserted a record the data was shown.

  5. By the way I should use the following URI:

    MONGO_URL=”mongodb://” meteor run –port 3333

    Note the “meteor” after the dash, and the IP notation.

Leave a Reply

Your email address will not be published. Required fields are marked *