title: getting ReplicaSetNoPrimary and MongoServerSelectionError error while connecting MongoDB with nodejs
body: <p>I am trying to connect to mongodb but getting below error could you please help</p>
  
  <pre><code>var mongo = require('mongodb').MongoClient;
  mongo.connect('mongodb://usernamexyz:passwordxyz@hostmxy-mw-e6-u1238.nam.nsroot.net:47017/sampleDB?replicaSet=NAME_2436&amp;readPreference=primary&amp;authSource=admin&amp;w=1', { useNewUrlParser: true, useUnifiedTopology: true  })
  .then(() =&gt; console.log("Mongodb connected"))
  .catch(err =&gt; console.log(err));
  </code></pre>
  
  <p>And the error i am getting as below</p>
  
  <pre><code>MongoServerSelectionError: connection &lt;monitor&gt; to 155.30.360.129:37017 closed
      at Timeout._onTimeout (C:\Fintech\NodeFirstApp\node_modules\mongodb\lib\core\sdam\topology.js:448:30)
      at listOnTimeout (internal/timers.js:531:17)
      at processTimers (internal/timers.js:475:7) {
    name: 'MongoServerSelectionError',
    reason: TopologyDescription {
      type: 'ReplicaSetNoPrimary',
      setName: null,
      maxSetVersion: null,
      maxElectionId: null,
      servers: Map {
        'hostmxy-mw-e6-u1238.nam.nsroot.net:47017' =&gt; [ServerDescription]
      },
      stale: false,
      compatible: true,
      compatibilityError: null,
      logicalSessionTimeoutMinutes: null,
      heartbeatFrequencyMS: 10000,
      localThresholdMS: 15,
      commonWireVersion: null
    },
    [Symbol(mongoErrorContextSymbol)]: {}
  }
  </code></pre>