title: MongoDB - ReplicaSet - Failed to refresh key cache
body: <p>I am deploying my first replica set on a Windows 10 machine with MongoDB 5.0.
  For the purpose of the tutorial, I want all the servers running on my machine, on different ports.</p>
  <p><strong>A)</strong></p>
  <p>I created my first server with :</p>
  <pre><code>mongod --replSet rs0 --port 27018 --dbpath C:\data\R0S1
  </code></pre>
  <p>I opened another command line prompt and I connected to it with <code>mongo --port 27018</code>.
  I iniated the set with the command <code>rs.initiate()</code>.</p>
  <p><strong>B)</strong></p>
  <p>I created my second and third server with :</p>
  <pre><code>mongod --replSet rs0 --port 27019 --dbpath C:\data\R0S2
  mongod --replSet rs0 --port 27020 --dbpath C:\data\R0S3
  </code></pre>
  <p>(I ran each of these commands in new command line prompts)</p>
  <p><strong>C)</strong></p>
  <p>I added the second and third server to the set by connecting to the primary server (on 27018
  with <code>mongo --port 27018</code>) with  :</p>
  <pre><code>rs.add(&quot;localhost:27019&quot;)
  rs.add(&quot;localhost:27020&quot;)
  </code></pre>
  <p>At this stage, everything has worked as expected.
  Running <code>rs.conf()</code> gives me :</p>
  <pre><code>{
          &quot;_id&quot; : &quot;rs0&quot;,
          &quot;version&quot; : 5,
          &quot;term&quot; : 1,
          &quot;members&quot; : [
                  {
                          &quot;_id&quot; : 0,
                          &quot;host&quot; : &quot;localhost:27018&quot;,
                          &quot;arbiterOnly&quot; : false,
                          &quot;buildIndexes&quot; : true,
                          &quot;hidden&quot; : false,
                          &quot;priority&quot; : 1,
                          &quot;tags&quot; : {
  
                          },
                          &quot;secondaryDelaySecs&quot; : NumberLong(0),
                          &quot;votes&quot; : 1
                  },
                  {
                          &quot;_id&quot; : 1,
                          &quot;host&quot; : &quot;localhost:27019&quot;,
                          &quot;arbiterOnly&quot; : false,
                          &quot;buildIndexes&quot; : true,
                          &quot;hidden&quot; : false,
                          &quot;priority&quot; : 1,
                          &quot;tags&quot; : {
  
                          },
                          &quot;secondaryDelaySecs&quot; : NumberLong(0),
                          &quot;votes&quot; : 1
                  },
                  {
                          &quot;_id&quot; : 2,
                          &quot;host&quot; : &quot;localhost:27020&quot;,
                          &quot;arbiterOnly&quot; : false,
                          &quot;buildIndexes&quot; : true,
                          &quot;hidden&quot; : false,
                          &quot;priority&quot; : 1,
                          &quot;tags&quot; : {
  
                          },
                          &quot;secondaryDelaySecs&quot; : NumberLong(0),
                          &quot;votes&quot; : 1
                  }
          ],
          &quot;protocolVersion&quot; : NumberLong(1),
          &quot;writeConcernMajorityJournalDefault&quot; : true,
          &quot;settings&quot; : {
                  &quot;chainingAllowed&quot; : true,
                  &quot;heartbeatIntervalMillis&quot; : 2000,
                  &quot;heartbeatTimeoutSecs&quot; : 10,
                  &quot;electionTimeoutMillis&quot; : 10000,
                  &quot;catchUpTimeoutMillis&quot; : -1,
                  &quot;catchUpTakeoverDelayMillis&quot; : 30000,
                  &quot;getLastErrorModes&quot; : {
  
                  },
                  &quot;getLastErrorDefaults&quot; : {
                          &quot;w&quot; : 1,
                          &quot;wtimeout&quot; : 0
                  },
                  &quot;replicaSetId&quot; : ObjectId(&quot;61cc297329dca2f0673c2cff&quot;)
          }
  }
  </code></pre>
  <p><strong>D)</strong> In a new command line prompt, I create my fourth server (with the idea of making it an arbiter) with :</p>
  <pre><code>mongod --replSet rs0 --port 30000 --dbpath C:\data\arb
  </code></pre>
  <p>Here I have a problem.
  The log file for this new server contains the following error :</p>
  <blockquote>
  <p>{&quot;t&quot;:{&quot;$date&quot;:&quot;2021-12-29T10:50:51.767+01:00&quot;},&quot;s&quot;:&quot;I&quot;,  &quot;c&quot;:&quot;-&quot;,<br />
  &quot;id&quot;:4939300, &quot;ctx&quot;:&quot;monitoring-keys-for-HMAC&quot;,&quot;msg&quot;:&quot;Failed to
  refresh key cache&quot;,&quot;attr&quot;:{&quot;error&quot;:&quot;NotYetInitialized: Cannot use
  non-local read concern until replica set is finished
  initializing.&quot;,&quot;nextWakeupMillis&quot;:19200}}</p>
  </blockquote>
  <p>When connecting to the primary and trying to do &quot;rs.addArb(localhost:30000)&quot;, the command blocks and does nothing, because of the above error on server on port 30000 I believe.</p>
  <p>Do you have any ideas on what's going on and how I could solve my issue ?</p>
  <p>----  edit 1 ----</p>
  <p>below is my mongod.cfg file :</p>
  <pre><code># mongod.conf
  
  # for documentation of all options, see:
  #   http://docs.mongodb.org/manual/reference/configuration-options/
  
  # Where and how to store data.
  storage:
    dbPath: C:\Program Files\MongoDB\Server\5.0\data
    journal:
      enabled: true
  #  engine:
  #  wiredTiger:
  
  # where to write logging data.
  systemLog:
    destination: file
    logAppend: true
    path:  C:\Program Files\MongoDB\Server\5.0\log\mongod.log
  
  # network interfaces
  net:
    port: 27017
    bindIp: 127.0.0.1
  
  
  #processManagement:
  
  #security:
  
  #operationProfiling:
  
  #replication:
  
  #sharding:
  
  ## Enterprise-Only Options:
  
  #auditLog:
  
  #snmp:
  </code></pre>