MeteorUp: Unable to connect from MeteorJs app to external MongoDB db, on linux machine

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? I am able to connect to the external MongoDB database(mlab.com) using a client tool(Studio 3T) so I know that the connection string is not an issue.

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> (/builtapp/programs/server/npm/nodemodules/meteor/npm-mongo/nodemodules/mongodb-core/lib/topologies/server.js:564:11)
at emitOne (events.js:115:13)
at Pool.emit (events.js:210:7)
at Connection.<anonymous> (/builtapp/programs/server/npm/nodemodules/meteor/npm-mongo/nodemodules/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> (/builtapp/programs/server/npm/nodemodules/meteor/npm-mongo/nodemodules/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/nexttick.js:138:11)
at process.tickDomainCallback (internal/process/nexttick.js:218:9)
=> Starting meteor app on port:80
/builtapp/programs/server/nodemodules/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
  },
};

It’s hard to say - perhaps you’ve just redacted the information, but the error: ENOTFOUND mongodb mongodb:27017 would indicate that you haven’t configured your hostname correctly - possibly on your dev machine you have a /etc/hosts entry for this? You’d need to configure the target machine (the one Meteor will run on, not the one you’re deploying from), or its probably better to just use the IP address of the server

1 Like

Hoping your MONGO_URL is right as you are able to connect as you state. Your MONGO_OPLOG_URL is certainly wrong. It has to be in the format mongodb://XX.XX.XX.XX:27017/local. Probably error is coming due to wrong OPLOG entry

2 Likes

Agree with @perumalkuk.
MUP / docker uses custom hostnames like this to reference other containers. If you’re not running a local mongo container (since you are using mlab), then this won’t connect to anything

This error also points to the same problem:

curl: (7) Failed to connect to 172.17.0.3 port 80: Connection refused

Error: failed to connect to server [mongodb:27017] on first connect

You can see that it’s converting mongodb to 172.17.0.3, and docker often uses the 172 subnets for inter-container networking

1 Like