Search code examples
mongodbmeteormongodb-atlas

Problem running meteor locally with a mongodb restored from Atlas snapshot


I want to run a localhost meteor locally to debug using data from production database.

I downloaded a daily snapshot fro Mongo Atlas, extracted it to desktop, unzipped it to a folder called "snap"

Then I run:

mongod --dbpath snap -port 3001

I can see the mongodb now running at 127.0.0.1:3001.

I go to start my meteor project locally:

meteor --settings settings.json

Hoping that it will somehow magically pick up the running database at port 3001, but it didnt.

It complains:

=> Started proxy.                             
Unexpected mongo exit code 48. Restarting.    
=> Meteor 2.1 is available. Update this project with 'meteor update'.
Unexpected mongo exit code 48. Restarting.    
Unexpected mongo exit code 48. Restarting.    
Can't start Mongo server.                     
MongoDB exited because its port was closed, or was already
taken by a previous instance of MongoDB

Check for other processes listening on port 3001
or other Meteor instances running in the same project.

What should I do to ask Meteor to start the project using that recovered database?


Solution

  • Assuming your DB is running, you can run locally with your own DB using the environment variable MONGO_URL

    $ MONGO_URL=mongodb://localhost:<port>/<dbname> meteor run --settings settings.json
    

    Note, that you need to set an explicit name for the db and if your Meteor db already contains data, then you need to import it into this db in order to have access to both.

    Furthermore, I would personally avoid setting port 3001 to not confuse it with the db that is bundled with Meteor. You should be fine with Mongo's defualt 27017 port.

    References:

    https://docs.meteor.com/environment-variables.html#MONGO-URL