0

After typing mongod I got the log below:

2015-11-21T21:51:11.424-0800 I JOURNAL  [initandlisten] journal dir=/data/db/journal
2015-11-21T21:51:11.424-0800 I JOURNAL  [initandlisten] recover : no journal files present, no recovery needed
2015-11-21T21:51:11.438-0800 I JOURNAL  [durability] Durability thread started
2015-11-21T21:51:11.439-0800 I CONTROL  [initandlisten] MongoDB starting : pid=22458 port=27017 dbpath=/data/db 64-bit host=(name)-MBP
2015-11-21T21:51:11.439-0800 I CONTROL  [initandlisten] 
2015-11-21T21:51:11.439-0800 I JOURNAL  [journal writer] Journal writer thread started
2015-11-21T21:51:11.439-0800 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2015-11-21T21:51:11.439-0800 I CONTROL  [initandlisten] db version v3.0.7
2015-11-21T21:51:11.439-0800 I CONTROL  [initandlisten] git version: nogitversion
2015-11-21T21:51:11.439-0800 I CONTROL  [initandlisten] build info: Darwin yosemitevm.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2015-11-21T21:51:11.439-0800 I CONTROL  [initandlisten] allocator: system
2015-11-21T21:51:11.439-0800 I CONTROL  [initandlisten] options: {}
2015-11-21T21:51:11.456-0800 I NETWORK  [initandlisten] waiting for connections on port 27017

It seems like I am having a warning and an error but is connected.

Now, I'm following MongoDB's document to test out how the database works. In one of the tutorials, it tells me to import a json file into my mongo db.

I input the following:

mongoimport --db test --collection restaurants --drop --file primer-dataset.json

and the result is :

2015-11-21T21:57:36.533-0800    [........................] test.restaurants 0.0 B/11.3 MB (0.0%)
2015-11-21T21:57:37.066-0800    Failed: error connecting to db server: no reachable servers
2015-11-21T21:57:37.066-0800    imported 0 documents

Can anyone tell me how to fix this problem?

I did brew update to update everything. So my mongodb version is 3.0.7 (the latest one) And I'm in development mode using homebrew.

1
  • have you started mongo server? with mongod? Commented Nov 22, 2015 at 6:54

1 Answer 1

2

As the error message says:

Failed: error connecting to db server: no reachable servers

The first step would be to test, whether the MongoDB server can be reached by hand. To do that, type

mongo

in a command line shell. If it does not work, the problem might be due to a firewall setting. (The MongoDB port, which is 27017 by default, might be blocked).

Also, you gave the mongod command and the output. To make sure that mongod is still running, you can type

ps aux | grep mongod

in the shell.

Sign up to request clarification or add additional context in comments.

4 Comments

it's not a right answer but you gave me an idea to solve the problem. thanks!
@Kahsn if this is not the completely working solution then you should post your answer which can be useful to future users and accept it. That is how things work around here.
@Kahsn: You are welcome. If you write an answer, it might help other people. (You can also write a short comment what was missing, or feel free to edit this post).
It was a stupid mistake on not running two terminals separately. I was using one terminal to do the operations. I dumped all connections first and connected to the database and opened new tab for a terminal to import the data. And it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.