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 trial

Databases Mongo Basics Getting Started With MongoDB Setting Up MongoDB

Problem with access to Mongodb in Mac

Hi, I installed mongodb with Homebrew early today. I use the command mongodb in shell but an exception occurred. Could anyone offer some help? below is the console message:

$ mongo 
MongoDB shell version v3.4.1
connecting to: mongodb://127.0.0.1:27017
2017-01-10T14:57:00.512+0800 W NETWORK  [main] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2017-01-10T14:57:00.515+0800 E QUERY    [main] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:234:13
@(connect):1:6
exception: connect failed

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

The database server, mongod, needs to be running so you can connect to it. The easiest way is to run it in a separate terminal tab/window. It's also possible to set it up as a service so it's run automatically, but I'm not familiar with MacOS to give instructions exact instructions.

Hi, I have solved the problem. I think the problem may be that I am not in the right path of mongo. Thank you all the same.