Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDerek Derek
8,744 PointsMongo connect failed
When I type bin/mongo, I get a connection failure, with this message.
MongoDB shell version: 3.2.6 connecting to: test 2016-05-05T01:18:28.047+0900 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused 2016-05-05T01:18:28.048+0900 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : connect@src/mongo/shell/mongo.js:229:14 @(connect):1:6
exception: connect failed
I deleted the .lock file, but it still fails. How can I get Mongo running? I am a Mac user. Thank you.
5 Answers
Joel Kraft
Treehouse Guest TeacherActually that output is referring to the grep process you're running from the command. There should be another line along with that one with the string mongod in it. Try running
$ ps aux | mongo
and see if that turns it up. I suspect you'll need to start the mongo daemon (or mongod) to get up and running. There are a lot of ways to go with a manual setup, but you should be able to do the following from the directory you are issuing the bin/mongo
command.
$ bin/mongod
If you see a bunch of text ending with something like waiting for connections on port 27017
, it should be running. Let it run in that terminal, and open another terminal to work in. Make sure you're in the right directory in the new window, and access the mongo shell the way you were trying to do before by typing
$ bin/mongo
Hope this helps! Let us know either way, and we'll keep working on it till you're in business.
Joel Kraft
Treehouse Guest TeacherMongo may not be running on your computer. Check this SO thread for help seeing if it's running.
Did you install with homebrew? Here are instructions for starting it.
Let us know if that worked for you, or if you need more help!
Derek Derek
8,744 PointsI think it is running.
$ ps -edaf | grep mongo
returns
501 12366 11787 0 4:13PM ttys000 0:00.00 grep mongo.
And I downloaded it manually. I tried downloading via Homebrew, but some kind of error occurred.
Joel Kraft
Treehouse Guest TeacherGreat!
When you communicate with any database, including mongo, it has to be running, and listening for your commands. That's what the daemon does. It receives commands and responds to them. If it's not running, nothing happens when you try to start the shell, because the shell has nothing to connect to.
Does that make sense?
Derek Derek
8,744 Pointsyes it does. Thank you so much!
Yosef Fastow
18,526 PointsI also had trouble with starting the shell on windows. I followed the advise and it seemed to work but stopped at connecting to: test and kind of froze. I ran the program again as an administrator and it worked!
Nicholas Braithwaite
6,612 PointsJust for anyone that comes to this page with a similar issue mongo was not set to run in the background for me so:
brew uninstall mongo
brew install mongo
brew services start mongodb
All working now!
Derek Derek
8,744 PointsDerek Derek
8,744 PointsI think it is running:
Hyuns-MacBook-Pro:mongodb-osx-x86_64-3.2.6 HyunJaeCho$ bin/mongo MongoDB shell version: 3.2.6 connecting to: test Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see http://docs.mongodb.org/ Questions? Try the support group http://groups.google.com/group/mongodb-user Server has startup warnings: 2016-05-06T03:27:04.922+0900 I CONTROL [initandlisten] 2016-05-06T03:27:04.922+0900 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Thank you so much!! One more question though, why did I have to run the daemon first?
Michael Brown
17,651 PointsMichael Brown
17,651 PointsI am having the same exact problem, except I am on a Windows Machine. I have tried everything you have said and it is still failing :/ Here is the text I got :
MongoDB shell version: 3.2.7 connecting to: test 2016-06-30T14:05:11.428-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-06-30T14:05:11.428-0400 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : connect@src/mongo/shell/mongo.js:229:14 @(connect):1:6
And when I try to do the ps | aux command Git tells me it does not recognize the command. (I am using the Git Bash terminal.)