MongoError: failed to connect to server [192.168.100.2:9001] on first connect - Meteor

I have a Meteor Application. I am trying to deploy my application by the custom deployment procedure (on my local machine) by following this article:

But I am facing this error when I run the application via node:

MongoError: failed to connect to server [192.168.100.2:9001] on first connect [MongoError: connect ECONNREFUSED 192.168.100.2:9001]
        at Object.wait (/home/martini-henry/myapp-build/bundle/programs/server/node_modules/fibers/future.js:449:15)
        at new MongoConnection (packages/mongo/mongo_driver.js:210:27)
        at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)
        at Object.<anonymous> (packages/mongo/remote_collection_driver.js:38:10)
        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 AccountsServer (packages/accounts-base/accounts_server.js:18:5)
        at server_main.js (packages/accounts-base/server_main.js:9:12)
        at fileEvaluate (packages/modules-runtime.js:343:9)
        - - - - -
        at Pool.<anonymous> (/home/martini-henry/myapp-build/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/topologies/server.js:336:35)
        at emitOne (events.js:96:13)
        at Pool.emit (events.js:188:7)
        at Connection.<anonymous> (/home/martini-henry/myapp-build/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/pool.js:280:12)
        at Connection.g (events.js:292:16)
        at emitTwo (events.js:106:13)
        at Connection.emit (events.js:191:7)
        at Socket.<anonymous> (/home/martini-henry/myapp-build/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/connection.js:187:49)
        at Socket.g (events.js:292:16)
        at emitOne (events.js:96:13)

Steps I performed:

First I came into the Meteor App directory and ran:

`meteor build ../myapp-build --architecture os.linux.x86_64`

Then I provided me the myapp.tar.gz and I extracted that.

Than I did:

 - cd programs/server && npm install
    - export MONGO_URL='mongodb://martini-henry:123456@192.168.100.2:9001/myappdb'
    - export ROOT_URL='http://192.168.100.2:9000'

And at last when I ran:

`- cd ../.. node main.js`

I got that error above. What could be wrong here? Can anyone help me what I am doing wrong here?

I suspect it’s this: export MONGO_URL='mongodb://martini-henry:123456@192.168.100.2:9001/myappdb'

For a production meteor installation you need to provide your own MongoDB - either hosted yourself (follow the MongoDB installation guidelines) or on a service provider (Atlas, mlab, compose, etc). By default, that will listen on port 27017 (not 9001).

If you’ve already installed MongoDB and mongod is running, you may just need to change the port number: export MONGO_URL='mongodb://martini-henry:123456@192.168.100.2:27017/myappdb'. Note that if mongod is configured to listen on localhost only, and your meteor application is on the same host as MongoDB, you’ll need export MONGO_URL='mongodb://martini-henry:123456@localhost:27017/myappdb'.

Having said that, MongoDB configuration and setup is tricky, particularly when you want oplog tailing. In that case, you may be better off going for a hosted offering where that’s done for you.

If you’re happy with doing your own devops, then mup is a good alternative (there are others).

1 Like

I ran

export MONGO_URL='mongodb://martini-henry:123456@localhost:27017/myappdb'

and now I am getting


MongoError: Authentication failed.

martini-henry:123456 is a username:password. You will need to use the username and password for a user defined in the database. See the docs for more on this.

If you have disabled access control you should be able to connect with export MONGO_URL='mongodb://localhost:27017/myappdb'

this command is getting me to shell:

export MONGO_URL=‘mongodb://localhost:27017/myappdb’