node.js in a dockerfile cant connect to mongolabs via mongoose: getaddrinfo ESRCH

I have done some googling but haven’t found anything..

My setup is like this:
OS X, boot2docker, everything local except mongolabs database.

  • Routing paths with Traefik
  • Docker - What is the easiest way to launch phpunit testsuite
  • How to Configure Nexus Sonatype docker image for inbound SSL?
  • Docker oracle database fails when starting after commiting
  • How do I create a docker machine with a specific URL using docker-machine and VirtualBox?
  • Is it possible to run ASP.NET Core application in IBM Containers for Bluemix?
  • The project is working fine when it’s not inside docker.

    I am trying to run my nodejs project inside a docker image. I have done this before, but not with a database connection requirement. The problem is that my node app crashes on startup with the information:

        process.nextTick(function() { throw err; })
        Error: getaddrinfo ESRCH
            at errnoException (dns.js:37:11)
            at Object.onanswer [as oncomplete] (dns.js:124:16)

    Does anyone have any idea how to solve this? Is there a DNS flag inside docker that can be set or is anything blocking my connection to the outside?


    I connect to my mongodb on mongolabs through mongoose.

    var configDB = require('./config/database.js');    

    and my passport.js file looks like this:

    module.exports = {
        'url' : 'mongodb://<user>:<password>

  • Can Docker containers (NOT Docker images) be moved?
  • How can I make my Docker compose “wait-for-it” script invoke the original container ENTRYPOINT or CMD?
  • Not able to ssh using private key
  • cucumber tests on docker won't fire at the integration-test phase
  • How to get services and its status inside the docker containers?
  • How to use other buildpacks with dokku-alt
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.