mongoDB external connection

Hello,

I would like to make mongodb accessible from other clients but I can’t find how.
I have two Meteor JS applications on two different machines and different IP, and I want to connect the second application to the first MONGODB database.

Could you tell me how to do that?

Thank you in advance.

You should use the MONGO_URL and MONGO_OPLOG_URL

1 Like

Hello there, I did exactly that once, here is how it works:

  1. Create two seperate meteor apps. Let’s say that App1 hosts the database, and App2 doesn’t make it’s own db, but uses the one from App1, ok?
  2. Run App1 normally. It will run your db usually under mongodb://localhost:3001/. Now we wanna connect to this db with the other app.
  3. Open a second terminal to run App2. Before running App2 set in that console it’s MONGO_URL env variable to the db from App1: export MONGO_URL=mongodb://localhost:3001/meteor. Check that it is set correctly echo $MONGO_URL.
  4. Run App2 under a new port (since port 3000 runs App1): meteor --port 3002.

So that’s how to do it locally during development. If you are using mup for deploying to production, have a look at this: http://meteor-up.com/docs.html#multiple-apps-use-the-same-database

1 Like

Sorry for the late response. Thank you for ur help :slight_smile: