Search code examples
ruby-on-railsruby-on-rails-3mongodbmongoidmoped

Moped::Errors::ConnectionFailure: Could not connect to any secondary or primary nodes


I have been trying to configure MongoDB (Mongoid) to work in my Rails application but I am helpless as I have tried pretty much everything I could find online yet I am getting this error message everytime there is a database line in my code. The repo for my app is here and the full message is this:

Moped::Errors::ConnectionFailure: Could not connect to any secondary or primary nodes for replica set <Moped::Cluster nodes=[<Moped::Node resolved_address="127.0.0.1:3000">]>

Update: Ran rs.status() on mongo shell, as per @BrandonBlack's suggestion, and got this:

{ "ok" : 0, "errmsg" : "not running with --replSet" }


Solution

  • The problem seemed to be that I had misconfigured the port for the databases in mongoid.yml, as it should only be 27017. I hope I don't need to revisit this question with another problem. :)