Report this

What is the reason for this report?

Unable to connect from MeteorJs application to external MongoDB database

Posted on September 16, 2019

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:**
[165.227.197.220] - Start Meteor: SUCCESS
[165.227.197.220] - 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 172.17.0.3 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
/built_app/programs/server/node_modules/fibers/future.js:313
                                                throw(ex);

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.