Mongo无法连接到OSX High Sierra 10.13.3上的localhost

时间:2018-02-03 06:46:34

标签: mongodb macos localhost macos-high-sierra

这适用于带有Mongoid的Rails 5应用程序。

显然mongoid.yml还可以。它适用于其他系统(例如OSX 10.11.6)。

test:
  clients:
    default:
      database: interview_test
      hosts:
       - localhost:27017

当我的应用尝试连接时,我得到:

Mongo::Error::NoServerAvailable:
   No server is available matching preference: #<Mongo::ServerSelector::Primary:0x70244985573080 tag_sets=[] max_staleness=nil> using server_selection_timeout=30 and local_threshold=0.015

经过多次搜索,我发现以下mongoid.yml 确实有效

     hosts:
      - 127.0.0.1:27017

这是/ etc / hosts:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost

为什么localhost不适用于High Sierra?怎么解决?

0 个答案:

没有答案