26

Whenever I type: rs.initiate(), I get the following error message:

{
    "info2" : "no configuration explicitly specified -- making one",
    "me" : "VMHOSTNAME:27017",
    "ok" : 0,
    "errmsg" : "No host described in new configuration 1 for replica set rs0 maps to this node",
    "code" : 93
}

I'm running under google-cloud-engine with latest MongoDB.

Any suggestions on how to solve this?

Vince Bowdren
  • 8,326
  • 3
  • 31
  • 56
Italo Maia
  • 1,956
  • 3
  • 18
  • 31
  • Have you tried making a replica set configuration explicitly? It sounds like the autoconfig process is having trouble coming up with a hostname that maps to the node, which is symptomatic of some networking problem. – wdberkeley Mar 06 '15 at 15:26

5 Answers5

35

You could try passing a parameter to the .initiate() command.

Like so:

rs.initiate({_id:"yourReplSetName", members: [{"_id":1, "host":"yourHost:yourPort"}]})

This did the trick for me.

LeBird
  • 728
  • 5
  • 17
31

Your VMHOSTNAME must be an alias for 127.0.0.1 in your /etc/hosts file to make it work.

See here https://jira.mongodb.org/browse/SERVER-16157

DanielKhan
  • 1,190
  • 1
  • 9
  • 18
  • 1
    In particular, it cannot be an alias for 127.0.1.1 as it is by default on Ubuntu, as pointed out in this answer: http://dba.stackexchange.com/questions/105035/unable-to-create-replica-set-for-mongodb-in-linux/105088#105088 – Jim Oldfield Aug 04 '16 at 09:58
15

The problem might be in your mongo config. Look for the following line and comment it out:

#bindIp: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.
Steffan Perry
  • 2,112
  • 1
  • 21
  • 21
0

Yeah, exactly, or you can change your hostname to something that is already in your /etc/hosts pointing to 127.0.0.1 such as localhost.

With a mac you can do this by typing sudo scutil –-set HostName localhost.

megalucio
  • 5,051
  • 2
  • 22
  • 26
0

If you find the VMHOSTNAME in the /etc/hostnames file and the referenced mongo instance is running then its possibly a port number error. In my case it was. Shards tipically started at port 27018.

yImI
  • 121
  • 1
  • 5