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

Yuichi Narisawa
Yuichi Narisawa
19,548 Points

connect failed...

I'm on the MacOS Sierra ver 10.12.6, and installed via homebrew. When I run mongo, I've got following error.

MongoDB shell version v3.4.9 connecting to: mongodb://127.0.0.1:27017 2017-09-15T15:55:26.489+0900 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused 2017-09-15T15:55:26.489+0900 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : connect@src/mongo/shell/mongo.js:237:13 @(connect):1:6 exception: connect failed

I've read other threads of the same/similar problems, and tried several suggestions but it doesn't work...

When I run mongod, I've got 2017-09-15T16:02:48.192+0900 I CONTROL [initandlisten] MongoDB starting : pid=72181 port =27017 dbpath=/data/db 64-bit host=mbp2015.local 2017-09-15T16:02:48.193+0900 I CONTROL [initandlisten] db version v3.4.9 2017-09-15T16:02:48.193+0900 I CONTROL [initandlisten] git version: 876ebee8c7dd0e2d992f 36a848ff4dc50ee6603e 2017-09-15T16:02:48.193+0900 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2l 25 May 2017 2017-09-15T16:02:48.193+0900 I CONTROL [initandlisten] allocator: system

2017-09-15T16:02:48.193+0900 I CONTROL [initandlisten] modules: none 2017-09-15T16:02:48.193+0900 I CONTROL [initandlisten] build environment: 2017-09-15T16:02:48.193+0900 I CONTROL [initandlisten] distarch: x86_64 2017-09-15T16:02:48.193+0900 I CONTROL [initandlisten] target_arch: x86_64 2017-09-15T16:02:48.193+0900 I CONTROL [initandlisten] options: {} 2017-09-15T16:02:48.195+0900 I - [initandlisten] Detected data files in /data/db c reated by the 'wiredTiger' storage engine, so setting the active storage engine to 'wired Tiger'. 2017-09-15T16:02:48.195+0900 I STORAGE [initandlisten] wiredtiger_open config: create,ca che_size=7680M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false ,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_ma nager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0), 2017-09-15T16:02:48.201+0900 E STORAGE [initandlisten] WiredTiger error (13) [1505458968 :201112][72181:0x7fffb5e323c0], file:WiredTiger.wt, connection: /data/db/WiredTiger.turtl e: handle-open: open: Permission denied 2017-09-15T16:02:48.214+0900 I - [initandlisten] Assertion: 28595:13: Permission d enied src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 269 2017-09-15T16:02:48.216+0900 I STORAGE [initandlisten] exception in initAndListen: 28595 13: Permission denied, terminating 2017-09-15T16:02:48.216+0900 I NETWORK [initandlisten] shutdown: going to close listenin g sockets... 2017-09-15T16:02:48.216+0900 I NETWORK [initandlisten] removing socket file: /tmp/mongod b-27017.sock 2017-09-15T16:02:48.216+0900 I NETWORK [initandlisten] shutdown: going to flush diaglog. .. 2017-09-15T16:02:48.217+0900 I CONTROL [initandlisten] now exiting 2017-09-15T16:02:48.217+0900 I CONTROL [initandlisten] shutting down with code:100

Any suggestions?

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Yuichi -

Sounds like a similar situation as to this post have a look at my answer there and post back if you are still stuck.

Happy coding, Ken

Yuichi Narisawa
Yuichi Narisawa
19,548 Points

After the post, I carefully read the error. Then I noticed it complained about the permission so I tried sudo and it worked! Thanks for your suggestion!