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

Anthony c
Anthony c
20,907 Points

Getting error with mongo command

MYNAME-MacBook-Air:~ MYNAME$ mongo
MongoDB shell version: 3.2.0
connecting to: test
2015-12-29T16:32:25.605-0500 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2015-12-29T16:32:25.608-0500 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:224:14
@(connect):1:6

exception: connect failed
MYNAME-MacBook-Air:~ MYNAME$

3 Answers

jason chan
jason chan
31,009 Points

you have to run two terminals

one for mongod first as server
second mongo as shell

I hope this help someone.

Michael Watson
STAFF
Michael Watson
Treehouse Teacher

I had some issues with this myself. Try rewatching from 2 mins, and considering the advice from Anthony c and Jason Chan as both were helpful comments as I troubleshot locally. It's working for me now. Also, I had to run

mongod

in one terminal first, then

mongo

in the next and it worked.

Thanks Anthony!