Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 506 Vote(s) - 3.48 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mongo - ruby connection problem

#1
I have installed mongo and bson_ext
now I have created a .rb file with the following contents ::

require 'rubygems'
require 'mongo'

db = Mongo::Connection.new.db("mydb")
db = Mongo::Connection.new("localhost").db("mydb")
db = Mongo::Connection.new("localhost", 27017).db("mydb")


However I am getting following error on running the code

yuzaki@ubuntu:~$ ruby firstruby.rb
/home/ryuzaki/.rvm/gems/ruby-1.9.2-p136/gems/mongo-1.2.0/lib/mongo/connection.rb:451:in `connect': Failed to connect to a master node at localhost:27017 (Mongo::ConnectionFailure)
from /home/ryuzaki/.rvm/gems/ruby-1.9.2-p136/gems/mongo-1.2.0/lib/mongo/connection.rb:554:in `setup'
from /home/ryuzaki/.rvm/gems/ruby-1.9.2-p136/gems/mongo-1.2.0/lib/mongo/connection.rb:98:in `initialize'
from firstruby.rb:4:in `new'
from firstruby.rb:4:in `<main>'

Please help!

Reply

#2
If you're on a Mac and used Brew, restarting the service solved it for me:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist

You can find this info by running `brew info mongodb`.
Reply

#3
Sometimes there is simply not enough space.

> exception in initAndListen: 15926 Insufficient free space for
> journals, terminating
Reply

#4
On a mac, using brew I found that `brew info mongodb` and then using then

`ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents` or `mongod --config /usr/local/etc/mongod.conf` worked!
Reply

#5
I just encountered this due to my /etc/hosts file not containing an entry for "localhost" - consequently Ruby couldn't resolve "localhost". I suppose you can hardcode 127.0.0.1 into your code rather than "localhost" - or fix /etc/hosts to contain:

> 127.0.0.1 localhost
Reply

#6
had this happen several times now, and here is the solution that works for me:

sudo rm /var/lib/mongodb/mongod.lock
sudo -u mongodb mongod -f /etc/mongodb.conf --repair
sudo start mongodb
sudo status mongodb

Reply

#7
This is definitely due to your mongo server not running. Since you're on Ubuntu, try doing a `sudo /etc/init.d/mongodb start` and then see if your code works.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through