Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-4534

Unable to connect with v1.24.1 - Error: getaddrinfo ENOTFOUND mongodb

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • 1.24.6
    • Affects Version/s: 1.24.1
    • Component/s: Compass
    • None
    • Environment:
      Windows 10 Desktop
    • Not Needed
    • Iteration Star Apple

      Problem Description

      I am no longer able to connect to MongoDB using *Compass 1.24.1*.
      I am able to connect using Compass 1.23.0.

      In v1.24.1, connections fail with a getaddrinfo ENOTFOUND mongodb error.
      Connecting with any other application such as a 3rd party app (NoSQLBooster) works fine.
      See the screenshot below:

       

      I tested this on a second machine where I still had v1.23.0 installed.  The connection worked prior to upgrading to v1.24.1. It immediately stopped working after the upgrade. See screenshot, which shows before and after:

      Steps to Reproduce

      (1) Create a single node MongoDB Community Instance on a LAN

      (2) Use the connection string to connect.

      Expected Results

      Successful connection.

      Actual Results

      Error: getaddrinfo ENOTFOUND mongodb

      Observations

      When I enter a connection string into *Compass v1.24.1* such as:

      mongodb://user:XXXXX@HOSTNAME.com:27017/ops?authSource=admin

      Compass expands the connection string with default values to become:

      mongodb://user:XXXXX@HOSTNAME.com:27017/ops?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=false

      This expansion happens in both 1.24.1 and 1.23.0 but the connection only fails in v1.24.1. It works fine in v1.23.0. If I use the first connection string in a different app such as NoSQLBooster, the connection works fine. But if I use the altered connection string in that app with &readPreference=primary, it fails with the same error that Compass fails with. I only provide this detail as a trace from NoSQLBooster as it might shed light on the Compass issue.

      The issue appears that the fully expanded connection string is being passed to the server. I'm not sure why this fails when the parameter is added. I can only speculate that the MongoDB server instance (in this case, community edition used for testing), is rejecting the connection due to the presence of the string. 

      TEST 1 (Failure)

      This shows the FAILED connection with the exact same error that Compass returns using the connection string:
      mongodb://user:XXXXX@HOSTNAME.com:27017/ops?authSource=admin&readPreference=primary

      Although this is a trace from a different application, it may shed light on the issue with Compass.

      Version: 6.2.4OS: {"platform":"win32","type":"Windows_NT","release":"10.0.19042","mem":"32G"}Brief:
      Connect to HOSTNAME.com Status:Failed Duration:Error:
      MongoNetworkError: failed to connect to server [mongodb:27017] on first connect [Error: getaddrinfo ENOTFOUND mongodbDetails:
      10:34:57.766 *** Starting "Discover Replica Set" to get rs name***10:34:57.994 *** Finished "Discover Replica Set" 228 ms ***
      {{

      {"hosts":[\{"host":"mongodb","port":27017,"role":"primary"}

      ],"setName":"rs0"}}}10:34:57.995 *** Starting MongoClient.connect ***
      {{

      {"options":\{"appname":"NoSQLBoosterV6.2.4_94929.153","autoReconnect":true,"keepAlive":60000,"minSize":1,"poolSize":1,"promoteLongs":false,"promoteValues":false,"reconnectTries":172800,"sslValidate":false,"useNewUrlParser":true,"useUnifiedTopology":false}

      ,"uri":"mongodb://user:******@HOSTNAME.com:27017/ops?authSource=admin&readPreference=primary&replicaSet=rs0"}}}10:34:57.998 Topology Opening
      {{

      {"topologyId":5}

      }}10:34:58.007 Server Opening
      {{

      {"address":"HOSTNAME.com:27017","topologyId":5}

      }}10:34:58.097 Server Description Changed
      {{

      {"address":"HOSTNAME.com:27017","newDescription":\{"address":"HOSTNAME.com:27017","arbiters":[],"hosts":[],"passives":[],"type":"RSPrimary"}

      ,"previousDescription":{"address":"HOSTNAME.com:27017","arbiters":[],"hosts":[],"passives":[],"type":"Unknown"}}}}10:34:58.097 Server Closed
      {{

      {"address":"HOSTNAME.com:27017","topologyId":5}

      }}10:34:58.103 Server Opening
      {{

      {"address":"mongodb:27017","topologyId":5}

      }}10:35:00.379 Topology Description Changed
      {{

      {"diff":\{"servers":[]}

      ,"newDescription":{"servers":[],"setName":"rs0","topologyType":"Unknown"},"previousDescription":{"servers":[],"topologyType":"Unknown"},"topologyId":5}}}10:35:00.379 Server Closed
      {{

      {"address":"mongodb:27017","topologyId":5}

      }}10:35:00.379 Topology Closed
      {{

      {"topologyId":5}

      }}10:35:00.380 Topology Description Changed
      {{

      {"diff":\{"servers":[]}

      ,"newDescription":{"servers":[],"setName":"rs0","topologyType":"Unknown"},"previousDescription":{"servers":[],"setName":"rs0","topologyType":"Unknown"},"topologyId":5}}}10:35:00.380 Topology Closed
      {{

      {"topologyId":5}

      }}10:35:00.380 *** Connect Error ***
      {{

      {"message":"failed to connect to server [mongodb:27017] on first connect [Error: getaddrinfo ENOTFOUND mongodb\n at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26) \{\n name: 'MongoNetworkError'\n}

      ]","name":"MongoNetworkError","stack":"MongoNetworkError: failed to connect to server [mongodb:27017] on first connect [Error: getaddrinfo ENOTFOUND mongodb\n at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26) {\n name: 'MongoNetworkError'\n}]\n at Pool.<anonymous> (C:\\Users\\LesterWaters\\AppData\\Local\\Programs\\nosqlbooster4mongo\\resources\\app.asar\\node_modules\\mongodb\\lib\\core\\topologies\\server.js:438:11)\n at Pool.emit (events.js:203:13)\n at C:\\Users\\LesterWaters\\AppData\\Local\\Programs\\nosqlbooster4mongo\\resources\\app.asar\\node_modules\\mongodb\\lib\\core\\connection\\pool.js:562:14\n at C:\\Users\\LesterWaters\\AppData\\Local\\Programs\\nosqlbooster4mongo\\resources\\app.asar\\node_modules\\mongodb\\lib\\core\\connection\\pool.js:1009:9\n at C:\\Users\\LesterWaters\\AppData\\Local\\Programs\\nosqlbooster4mongo\\resources\\app.asar\\node_modules\\mongodb\\lib\\core\\connection\\connect.js:32:7\n at callback (C:\\Users\\LesterWaters\\AppData\\Local\\Programs\\nosqlbooster4mongo\\resources\\app.asar\\node_modules\\mongodb\\lib\\core\\connection\\connect.js:280:5)\n at Socket.<anonymous> (C:\\Users\\LesterWaters\\AppData\\Local\\Programs\\nosqlbooster4mongo\\resources\\app.asar\\node_modules\\mongodb\\lib\\core\\connection\\connect.js:310:7)\n at Object.onceWrapper (events.js:291:20)\n at Socket.emit (events.js:203:13)\n at emitErrorNT (internal/streams/destroy.js:91:8)\n at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)\n at processTicksAndRejections (internal/process/task_queues.js:77:11)"} }}

      TEST 2 (Success)

      This shows a successful connection where *readPreference=* is omitted from the connection string.

      mongodb://user:XXXXX@HOSTNAME.com:27017/ops?authSource=admin

      10:36:40.842 *** Starting MongoClient.connect ***
      {"options":\{"appname":"NoSQLBoosterV6.2.4_94929.153","autoReconnect":true,"keepAlive":60000,"minSize":1,"poolSize":1,"promoteLongs":false,"promoteValues":false,"reconnectTries":172800,"sslValidate":false,"useNewUrlParser":true,"useUnifiedTopology":false},"uri":"mongodb://user:******@HOSTNAME.com:27017/ops?authSource=admin"}10:36:40.949 Topology Opening
      {"topologyId":23}10:36:40.949 Server Opening
      {"address":"HOSTNAME.com:27017","topologyId":23}10:36:40.949 Server Description Changed
      {"address":"HOSTNAME.com:27017","newDescription":\{"address":"HOSTNAME.com:27017","arbiters":[],"hosts":[],"passives":[],"type":"RSPrimary"},"previousDescription":{"address":"HOSTNAME.com:27017","arbiters":[],"hosts":[],"passives":[],"type":"Unknown"}}10:36:40.949 Topology Description Changed
      {"address":"HOSTNAME.com:27017","newDescription":{"servers":[{"address":"HOSTNAME.com:27017","arbiters":[],"hosts":[],"passives":[],"type":"RSPrimary"}],"topologyType":"Single"},"previousDescription":{"servers":[{"address":"HOSTNAME.com:27017","arbiters":[],"hosts":[],"passives":[],"type":"Unknown"}],"topologyType":"Unknown"}}10:36:40.949 *** Finished MongoClient.connect 108 ms ***
      {"options":\{"appname":"NoSQLBoosterV6.2.4_94929.153","autoReconnect":true,"keepAlive":60000,"minSize":1,"poolSize":1,"promoteLongs":false,"promoteValues":false,"reconnectTries":172800,"sslValidate":false,"useNewUrlParser":true,"useUnifiedTopology":false},"uri":"mongodb://user:*****@HOSTNAME.com:27017/ops?authSource=admin"}10:36:40.950 *** Starting Detecting MongoDB Server BuildInfo ***10:36:40.953 *** Finished Detecting MongoDB Server BuildInfo 3 ms**
      }}{{10:36:40.953 Server Closed
      {"address":"HOSTNAME.com:27017","topologyId":23}
      10:36:40.954 Topology Closed
      {{{"topologyId":23} }}

       

       

       

       

        1. Compass_ENOTFOUND.png
          Compass_ENOTFOUND.png
          90 kB
        2. image-2020-12-10-11-48-06-545.png
          image-2020-12-10-11-48-06-545.png
          166 kB
        3. image-2020-12-10-11-48-21-028.png
          image-2020-12-10-11-48-21-028.png
          160 kB

            Assignee:
            rhys.howell@mongodb.com Rhys Howell
            Reporter:
            lesterw@iotahoe.com Lester Waters
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: