Error: MONGO_URL must be set in environment on Ubuntu 16.04


#1

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

echo $MONGO_URL
sudo echo $MONGO_URL

Both commands can print the value of $MONGO_URL correctly


#2

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

node main.js

Maybe that works? Xd


#3

If you use port 80 you need to sudo


#4

#5

This works! Thank you @abernix


#6

@abernix I have the same error on windows. I have to host a meteor app on windows.
WHAT DO I DO PLEASE!!!
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?


#7

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.


#8

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