Unable to connect from MeteorJs application to external MongoDB database

Posted September 16, 2019 4.2k views
MongoDBUbuntu 18.04

Hopefully this is a newbie question.

I am trying to deploy my MeteorJs application using MeteorUp and it is failing when trying to connect to the external MongoDB database. What am I missing? Do I need to configure mongod.conf (on the host) to add the external ip address that is allowed to connect to the external MongoDB database?

**MeteorUp logs:**
[] - Start Meteor: SUCCESS
[] - Verifying Deployment
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed to connect to port 80: Connection refused

Error: failed to connect to server [mongodb:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND mongodb mongodb:27017]
    at Pool.<anonymous> (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/topologies/server.js:564:11)
    at emitOne (events.js:115:13)
    at Pool.emit (events.js:210:7)
    at Connection.<anonymous> (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/pool.js:317:12)
    at Object.onceWrapper (events.js:318:30)
    at emitTwo (events.js:125:13)
    at Connection.emit (events.js:213:7)
    at Socket.<anonymous> (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/connection.js:246:50)
    at Object.onceWrapper (events.js:316:30)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
=> Starting meteor app on port:80

module.exports = {
  servers: {
    one: {
      host: '',
      username: 'root',
      pem: '../DigitalOcean-PrivateKey'
  app: {
    name: 'ToDoUsingReactAndMeteorJs',
    path: '../',
    servers: {
      one: {},
    buildOptions: {
      serverOnly: true,
    env: {
      ROOT_URL: '',
      MONGO_URL: 'mongodb://ajitgoel:<password>@host/commonmembership',
      MONGO_OPLOG_URL: 'mongodb://mongodb/local',
    docker: {
      image: 'abernix/meteord:node-8.4.0-base',
    enableUploadProgressBar: true
edited by bobbyiliev

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


I would recommend using telnet to test the connection between your web server and your MongoDB server:

  • SSH to your web server and then run:
telnet your_mongodb_ip_address mongodb_port

If you are not able to connect, then you need to make sure that your web server’s IP address is allowed on your MongoDB server so that they could communicate.

If you are able to connect on the other side, then it is most likely something in your connection string. I think that it should look something like this: