I try to add another net with the its corresponding bind ip and port to my AMI ec2 mongod.conf file so I will be able to create a 2 node replica set but when I run the command "sudo service mongos restart", mongos won't start. Here is my mongos.conf file:

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# Where and how to store data.
  dbPath: /var/lib/mongo
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# how the process runs
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile
  timeZoneInfo: /usr/share/zoneinfo

# network interfaces
  port: 27017
  bindIp: # Enter,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
  port: 27017


 replSetName: "Midterm"


## Enterprise-Only Options



Does anyone know why this is happening? I tried doing this in a vm using vagrant and it worked. Why would be any different in AMI ec2?


This is what the security group of one of my instances looks like: enter image description here

  • this works if I'm setting the replica set on 1 machine but im trying to create a 3 node replica set, meaning that I have 3 VMs and want to make a replica set where there is 1 instance on each machine
    – tom dinh
    Commented Mar 19, 2019 at 23:33
  • Try this linode.com/docs/databases/mongodb/create-a-mongodb-replica-set
    – Mani
    Commented Mar 20, 2019 at 0:01
  • the 1st node I made as primary couldn't find the second node to add to the replica set.
    – tom dinh
    Commented Mar 20, 2019 at 0:25
  • Are you able to connect to the MongoDB running on the second machine from the first machine through mongo shell? If not enable inbound ports in the second machine, check the config file binip as well.
    – Mani
    Commented Mar 20, 2019 at 0:30
  • if you mean ping, I can ping the bindIp of the machines on each other and there is a response
    – tom dinh
    Commented Mar 20, 2019 at 1:57


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.