Connecting Locally to MongoDB

You can run your Empirica experiment locally, whilst still connecting it to a cloud MongoDB database.

To do so, you need to create the database and obtain the URI.

Via the settings file

As explained in the guide for deploying to MongoDB, you will need to add these elements to your settings file:

    "": {
        "env": {
            "MONGO_URL": "mongodb+srv://<read&write username>:<read&write password>@<connection>/<database name>?retryWrites=true&w=majority",
            "MONGO_OPLOG_URL": "mongodb+srv://<oplog username>:<oplog password>@<connection>/local"

Fill in the <> parts with the appropriate elements.

Now you can run your app with:

meteor --settings <name of settings file>

This might not always work for connecting locally to your MongoDB. The method below is more reliable.

Via the command line

According to your OS, follow the instructions below to connect to your MongoDB via the command line.

Run this command with the URI you have obtained but without the ?retryWrites=true&w=majority

MONGO_URL=<MongoDB URI> meteor

Last updated