Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-455

Can't connect to the replica server where replica set is not initiated yet

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 0.7.7
    • Affects Version/s: None
    • Component/s: Embedded Shell
    • Labels:
      None
    • Not Needed

      Problem Description

      mongosh times out trying to connect to the mongodb server that is configured to be a replica set but where the replica is not initiated yet.

      Steps to Reproduce

      Create a mongodb server config similar to this:

      storage: 
        dbPath: ~/mongodb/replset/data
      net: 
        bindIp: localhost
        port: 27041
      security: 
        authorization: enabled
        keyFile: ~/mongodb/replset/keyfile
      systemLog: 
        destination: file
        path:  ~/mongodb/replset/mongod.log
        logAppend: true
      processManagement: 
        fork: true
      replication: 
        replSetName: replset
      

      Start the server with the mongod:

      mongod -f ./config.yml
      

      Connect to the server with mongosh:

      mongosh mongodb://localhost:27041/test
      

      Expected Results

      mongosh connects to the server without any issues

      Actual Results

      mongosh can't connect due to the timeout error:

      > mongosh mongodb://localhost:27041/test                                                                                                                                                                             
      
      < Current sessionID:  5fb7a1512ccac09e1bc8259a
      < Connecting to:      mongodb://localhost:27041/test
      < MongoServerSelectionError: Server selection timed out after 30000 ms
      

      Additional Notes

      • mongo shell can connect to the server created the same way with no issues
      • After replica set is initiated (for example through mongo shell with rs.initiate()), mongosh can connect to the server without any issues
      • mongod version 4.4.1
      • mongo version 4.4.1
      • mongosh version 0.5.2

            Assignee:
            Unassigned Unassigned
            Reporter:
            sergey.petushkov@mongodb.com Sergey Petushkov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: