Mongo :: Error :: NoServerAvailable when starting a Rails application

When starting up rails sand connecting to localhost: 3000, I get the following error messages when I try to execute simple requests, such as @users.each:

Mongo::Error::NoServerAvailable in Users#index

No server is available matching preference: #<Mongo::ServerSelector::Primary:0x62403672 tag_sets=[] server_selection_timeout=30 local_threshold=0.015>

Console shows

MONGODB | Adding localhost:3000 to the cluster
MONGODB | IOERROR

config / mongoid.yml

development:
  clients:
    default:
      database: virtu_development
      hosts:
        - localhost:3000
      options:

  options:
test:
  clients:
    default:
      database: virtu_test
      hosts:
        - localhost:3000
      options:
        read:
          mode: :primary
        max_pool_size: 1

Edit: when starting with mongoid.yml installed to run on the local host: 27017, as this seems to fit, the console reads repeatedly:

No connection could be made because the target machine actively refused it. - connect(2) for 127.0.0.1:27017

Edit 2: Launch mongo.exe, and in C:\Program Files\MongoDB\Server\3.2\bin:

MongoDB shell version: 3.2.4
connecting to: test
2016-03-31T19:14:03.597-0400 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:10061 No connection could be made because the target machine actively refused it.
2016-03-31T19:14:03.597-0400 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:224:14
@(connect):1:6

Running mongod.exegives:

2016-03-31T19:13:00.636-0400 I CONTROL  [initandlisten] MongoDB starting : pid=5564 port=27017 dbpath=C:\data\db\ 64-bit host=Kalyn-PC
2016-03-31T19:13:00.640-0400 I CONTROL  [initandlisten] targetMinOS: Windows Vista/Windows Server 2008
2016-03-31T19:13:00.640-0400 I CONTROL  [initandlisten] db version v3.2.4
2016-03-31T19:13:00.640-0400 I CONTROL  [initandlisten] git version: e2ee9ffcf9f5a94fad76802e28cc978718bb7a30
2016-03-31T19:13:00.640-0400 I CONTROL  [initandlisten] allocator: tcmalloc
2016-03-31T19:13:00.640-0400 I CONTROL  [initandlisten] modules: none
2016-03-31T19:13:00.640-0400 I CONTROL  [initandlisten] build environment:
2016-03-31T19:13:00.641-0400 I CONTROL  [initandlisten]     distarch: x86_64
2016-03-31T19:13:00.641-0400 I CONTROL  [initandlisten]     target_arch: x86_64
2016-03-31T19:13:00.641-0400 I CONTROL  [initandlisten] options: {}
2016-03-31T19:13:00.642-0400 I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory C:\data\db\ not found., terminating
2016-03-31T19:13:00.642-0400 I CONTROL  [initandlisten] dbexit:  rc: 100
+4
source share
2 answers

I had to manually

  • change config/mongoid.ymltolocalhost:27017

  • create empty directories C:data/db

  • mongod ( C:\Program Files\MongoDB\Server\3.2\bin mongod.exe).

rails server .

+2

mongodb rails, - localhost: 27017, (, db )

+1

All Articles