My mongodb instance will not run as standalone and I haven't been able to discover why. Its probably something simple. Please point me in the right direction.

Linux myserver 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

 mongo -version
MongoDB shell version v4.0.6

running the command:

mongo --host --port 27017 -u user -p mypassword


MongoDB shell version v3.4.13
connecting to: mongodb://admin:27017/?replicaSet=
2019-03-06T00:54:32.412-0500 I NETWORK  [thread1] Starting new replica set monitor for
2019-03-06T00:54:32.414-0500 I NETWORK  [thread1] getaddrinfo("admin") failed: Name or service not known
2019-03-06T00:54:32.414-0500 W NETWORK  [thread1] No primary detected for set
2019-03-06T00:54:32.414-0500 I NETWORK  [thread1] All nodes for set are down. This has happened for 1 checks in a row.
2019-03-06T00:54:32.914-0500 I NETWORK  [thread1] getaddrinfo("admin") failed: Name or service not known

So I logged into mongo shell on the host and ran:

use admin show users

        "_id" : "admin.myname",
        "user" : "myname",
        "db" : "admin",
        "roles" : [
                        "role" : "readWriteAnyDatabase",
                        "db" : "admin"
                        "role" : "root",
                        "db" : "admin"
                        "role" : "userAdminAnyDatabase",
                        "db" : "admin"
        "mechanisms" : [
        ] }



        "ok" : 0,
        "errmsg" : "not running with --replSet",
        "code" : 76,
        "codeName" : "NoReplicationEnabled"


# 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
  dbPath: /data/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.
  bindIpAll: true

  authorization: "enabled"




## Enterprise-Only Options



1 Answer 1


mongo --host --port 27017 -u user -p mypassword

The above command takes as replica set name and admin as the hostname. That is the reason you are getting the error.

Use any of the following commands to connect to your MongoDB database

mongo --port 27017 -u user -p mypassword

mongo admin --host --port 27017 -u user -p mypassword

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.