How to set up mongo_url in settings.json

I tried to google this problems, but still not find the solution. I think we still need more documentation and example about this.

this is my settings.json

    "MONGO_URL": "mongodb://"

and this is how i run it:
meteor --settings ./settings.json

but the meteor still connect to default mongodb localhost:3001.

where I wrong and how to solve this?

I remember once I had a similar problem but I then had to set the value of the process_env variable I change to the one from the settings. It was not for the database though. Could you try something like that ?

`process.env.MONGO_URL = Meteor.settings.MONGO_URL;

Also another solution would be to pass the MONGO_URL when launching the app. Instead of just “meteor” do:

MONGO_URL=mongodb:// meteor

You can also create a script in package.json for it:

"dev": "MONGO_URL=mongodb:// meteor"

Hope it helps

1 Like

The Manual says that MONGO URL is set by environnement variable not by settings


Hi @yozawiratama, did you manage to solve this? I am currently battling through this and for the life of me, I cannot stop my app connecting to the localhost:3001 MongoDB instance.

Actually, I just got this to work. Apparently, when running your app on localhost, you have to set the MONGO_URL env variable through the console when you fire up your app →
MONGO_URL=mongodb://localhost:27017/databasename meteor run

Posting for everyone’s reference.

Hello, sorry I just solve this with

create settings.json

    "MONGO_URL": "mongodb://"

and on server/main.js
add this on meteor startup
process.env.MAIL_URL = Meteor.settings.MAIL_URL;

and set on packages.json

"scripts": {

    "start": "meteor run --settings settings.json"


and last just run npm start

1 Like

you can check the usage in this repository. It’s the same as your solution

you can also use different settings.json on production.

Hi @yozawiratama, thanks for posting.

I assume in the main.js file, it should be:

process.env.MONGO_URL = Meteor.settings.MONGO_URL;



I use this command to start meteor with a non-normal db - and it works for me :slight_smile:

MONGO_URL=mongodb:// ‌meteor‌ ‌--settings‌ ‌ settingsLOC.json‌

settingsLOC.json contains no mongoURL settings.
DATABASENAME to be replaced with your db name, obviously :slight_smile:
(I use this to read back a dump from production db’s)