Error: MONGO_URL must be set in environment on Ubuntu 16.04

I’m trying to deploy my Meteor app to Ubuntu 16.04, I run

sudo nodejs main.js

It throws an error ,

Error: MONGO_URL must be set in environment
    at Object.<anonymous> (packages/mongo/remote_collection_driver.js:36:11)
    at Object.defaultRemoteCollectionDriver (packages/underscore.js:784:19)
    at new Mongo.Collection (packages/mongo/collection.js:99:40)
    at AccountsServer.AccountsCommon (packages/accounts-base/accounts_common.js:23:18)
    at new AccountsServer (packages/accounts-base/accounts_server.js:18:5)
    at meteorInstall.node_modules.meteor.accounts-base.server_main.js (packages/accounts-base/server_main.js:9:12)
    at fileEvaluate (packages/modules-runtime.js:197:9)
    at require (packages/modules-runtime.js:120:16)
    at /home/ubuntu/bundle/programs/server/packages/accounts-base.js:2019:15
    at /home/ubuntu/bundle/programs/server/packages/accounts-base.js:2030:3

But I have already set this environment variable, for example, I run

sudo echo $MONGO_URL

Both commands can print the value of $MONGO_URL correctly

Dunno if this makes a difference. But i always run meteor on ubuntu using:

node main.js

Maybe that works? Xd

If you use port 80 you need to sudo


This works! Thank you @abernix

@abernix I have the same error on windows. I have to host a meteor app on windows.
I need the app to be connected to the mongo_url.
how do I find the mongo url?
I only want the connection for this app alone, other meteor apps can continue with the default meteor mongo, is this possible?

There is no default MongoDB on a deployed Meteor app. You will need to install it yourself, or use an external provider. Only in development mode, does Meteor install a MongoDB for you.

If you’ve installed it yourself it will be something like mongodb://hostname:27017/databasename. If it’s an external provider, the correct URL will be available somewhere in your admin panel.

1 Like

Been able to get over that huddle.
Next challenge is how to get the URL set for only this particular application and not affect all other meteor applications, which is what setting an environment variable does. more here