我遇到MongoDB问题。
首先,在运行mongod
,然后mongo
(在另一个终端窗口中)时,我得到:
MongoDB shell version: 2.2.2
connecting to: test
>
>
然而。当我在Heroku app终端中输入rails console
时,我得到:
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'
.. 任何帮助将不胜感激。
答案 0 :(得分:0)
没有端口选项,mongod和mongo都使用默认端口号27017.来自rails控制台的输出报告它正在尝试连接到端口9100.请检查config / mongo.yml中与您相关的MongoMapper配置检查环境变量RAILS_ENV。