"Mongod" works, but running "rails console" results in "Failed to connect to a master node at 127.0.0.1:9100 (Mongo::ConnectionFailure)"

StackOverflow https://stackoverflow.com/questions/14916039

Pregunta

I have a problem with MongoDB.

For a start, when running mongod, and then mongo (in another teminal window), I get:

MongoDB shell version: 2.2.2
connecting to: test
> 
> 

However. When I type rails console in my Heroku app terminal, I get:

Failed to connect to a master node at 127.0.0.1:9100 (Mongo::ConnectionFailure)
from /Users/musetr/.rvm/gems/ruby-1.9.3-p327@rails3tutorial2ndEd/gems/mongo-1.6.4/lib/mongo/connection.rb:594:in `setup'
from /Users/musetr/.rvm/gems/ruby-1.9.3-p327@rails3tutorial2ndEd/gems/mongo-1.6.4/lib/mongo/connection.rb:130:in `initialize'
from /Users/mmusetr/.rvm/gems/ruby-1.9.3-p327@rails3tutorial2ndEd/gems/mongo_mapper-0.12.0/lib/mongo_mapper/connection.rb:79:in `new'
from /Users/musetr/.rvm/gems/ruby-1.9.3-p327@rails3tutorial2ndEd/gems/mongo_mapper-0.12.0/lib/mongo_mapper/connection.rb:79:in `connect'
from /Users/musetr/.rvm/gems/ruby-1.9.3-p327@rails3tutorial2ndEd/gems/mongo_mapper-0.12.0/lib/mongo_mapper/connection.rb:89:in `setup'

.. Any help would be greatly appreciated.

¿Fue útil?

Solución

Without port options, both mongod and mongo use the default port number 27017. The output from your rails console reports that it is trying to connect to port 9100. Please check your MongoMapper configuration in config/mongo.yml, correlated with your checking of environment variable RAILS_ENV.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top