Lab: Deploy a Sharded Cluster

I have edited the mongos.conf file to be:

  keyFile: /var/mongodb/pki/m103-keyfile
  bindIp: localhost
  port: 26000
  destination: file
  path: /var/mongodb/logs/mongos.log
  logAppend: true
  fork: true
  configDB: csrs/localhost:27004,localhost:27005,localhost:27006

I then run the command mongos -f mongos.conf to start mongos

I then try to authenticate to the database with the command mongo --port 2600 -u "m103-admin" -p "m103-pass" --authenticationDatabase "admin" but I get the error:

MongoDB shell version v4.0.5
connecting to: mongodb://
2020-11-24T22:00:03.868+0000 E QUERY    [js] Error: couldn't connect to server, connection attempt failed: SocketException: Error connecting to :: caused by :: Connection refused :
exception: connect failed

Any ideas on what I’m doing incorrectly?

Your --port is wrong. You started mongod at port 26000 yet you try to connect with port 2600.

1 Like

Hi @Eric_Kenney,

I hope you found @steevej-1495’s response helpful and you were able to resolve the issue.

Let us know if you are still facing any issues.

~ Shubham