Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4351

MongoClient ignores passed url and always use localhost

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Unknown
    • Resolution: Gone away
    • None
    • None
    • None
    • Not Needed

    Description

      What problem are you facing?

      While trying to connect to our mongodb at `mongo`, the driver tries to connect to localhost and times out:

      ```
      > (node:8625) UnhandledPromiseRejectionWarning: MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
      at Timeout._onTimeout (/builds/seervision/main/svms/node_modules/mongodb/lib/sdam/topology.js:312:38)
      at listOnTimeout (internal/timers.js:557:17)
      at processTimers (internal/timers.js:500:7)
      (Use `node --trace-warnings ...` to show where the warning was created)
      (node:8625) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see
      https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode
      ). (rejection id: 1)
      (node:8625) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
      ```

      What driver and relevant dependency versions are you using?

      Node `mongodb`  `4.7.0`

      Steps to reproduce?

      Have a mongo database running on any host but localhost. 

      ```
      const mongo = require('mongodb');
      const uri = "
      [mongodb://172.17.0.2:27017]
      "
      client = new mongo.MongoClient(uri)
      client.connect()
      ```

      Attachments

        Issue Links

          Activity

            People

              durran.jordan@mongodb.com Durran Jordan
              thibault@seervision.com Thibault Nicolas
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: