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 trialRebekah Shaw
18,687 PointsError when connecting to mongod
I have been trying to connect to the mongo server for over an hour but have had no joy. I installed mongoose, mongodb and mongo. when I ender mongod into the terminal I get the following message.
-bash: mongod: command not found
When I enter node mongoose_sandbox.js into the terminal I get the following message.
connection error: { Error: connect ECONNREFUSED 127.0.0.1:27017 at Object._errnoException (util.js:1003:13) at _exceptionWithHostPort (util.js:1024:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1195:14) name: 'MongoError', message: 'connect ECONNREFUSED 127.0.0.1:27017' }
I'm so confused and none of this is clear within the video.
3 Answers
Rebekah Shaw
18,687 PointsI installed it into the qa-rest-api folder
Rebekah Shaw
18,687 PointsI'm using OS X, I will try this and let you know if it works
Seth Kroger
56,414 PointsThe main issue is that mongod wasn't installed in the usual directories where executable files are searched for (the environment variable PATH) and if you installed it in the project's folder you need to specify the directory path to the mongod executable to run it.
Rebekah Shaw
18,687 Pointswhere is it meant to be installed?
Alexander La Bianca
15,959 PointsAre you on a OS X or Windows? On OS X you will want mongod to be installed in usr/local/bin . Same place where node and npm is installed. Your PATH should already expose that directory. I recommend you uninstall it and reinstall it with homebrew. It will add mongod to the correct directory for your.
Here is another guide that should help: It contains the correct way for doing it with Homebrew or Manual download.
https://treehouse.github.io/installation-guides/mac/mongo-mac.html
Rebekah Shaw
18,687 PointsAfter doing this I still get the same message.
-bash: mongod: command not found
Alexander La Bianca
15,959 PointsWhat operating system are you on? If on OS X if you do echo $PATH in the command line do you see usr/local/bin in the result?
Rebekah Shaw
18,687 PointsI think I have got it working now, thanks for your help :-)
Marshall Bradley
13,552 Pointsso um.... could you please share how you got it working?
Alexander La Bianca
15,959 PointsAlexander La Bianca
15,959 PointsIn what directory did you install mongo?