0

I have 2 terminal windows, first to run the server, the second one to use as a client to connect to the db server.
I have successfully connected to my local mongoDB server.

Terminal window 1

bogdanmac:~ iliebogdanbarbulescu$ bogdanmac:~ iliebogdanbarbulescu$ brew services start [email protected] Service `mongodb-community` already started, use `brew services restart mongodb-community` to restart. 

Unfortunately, I can not access the database from the client.

Terminal window 2

ilies-mbp:mongodb iliebogdanbarbulescu$ pwd /usr/local/var/mongodb ilies-mbp:mongodb iliebogdanbarbulescu$ ls WiredTiger diagnostic.data WiredTiger.lock index-1-454351138292104502.wt WiredTiger.turtle index-3-454351138292104502.wt WiredTiger.wt index-5-454351138292104502.wt WiredTigerLAS.wt index-6-454351138292104502.wt _mdb_catalog.wt journal collection-0-454351138292104502.wt mongod.lock collection-2-454351138292104502.wt sizeStorer.wt collection-4-454351138292104502.wt storage.bson ilies-mbp:mongodb iliebogdanbarbulescu$ mongo MongoDB shell version v4.2.5 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb 2020-04-16T17:13:02.269+0100 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused : connect@src/mongo/shell/mongo.js:341:17 @(connect):2:6 2020-04-16T17:13:02.271+0100 F - [main] exception: connect failed 2020-04-16T17:13:02.271+0100 E - [main] exiting with code 1 ilies-mbp:mongodb iliebogdanbarbulescu$ 

Logs at /usr/local/var/log/mongodb/mongo.log

2020-04-16T16:54:03.370+0100 I CONTROL [main] ***** SERVER RESTARTED ***** 2020-04-16T16:54:03.373+0100 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none' 2020-04-16T16:54:03.385+0100 W ASIO [main] No TransportLayer configured during NetworkInterface startup 2020-04-16T16:54:03.387+0100 I CONTROL [initandlisten] MongoDB starting : pid=76453 port=27017 dbpath=/usr/local/var/mongodb 64-bit host=bogdanmac.mynet 2020-04-16T16:54:03.387+0100 I CONTROL [initandlisten] db version v4.2.5 2020-04-16T16:54:03.387+0100 I CONTROL [initandlisten] git version: 2261279b51ea13df08ae708ff278f0679c59dc32 2020-04-16T16:54:03.387+0100 I CONTROL [initandlisten] allocator: system 2020-04-16T16:54:03.387+0100 I CONTROL [initandlisten] modules: none 2020-04-16T16:54:03.387+0100 I CONTROL [initandlisten] build environment: 2020-04-16T16:54:03.387+0100 I CONTROL [initandlisten] distarch: x86_64 2020-04-16T16:54:03.387+0100 I CONTROL [initandlisten] target_arch: x86_64 2020-04-16T16:54:03.387+0100 I CONTROL [initandlisten] options: { config: "/usr/local/etc/mongod.conf", net: { bindIp: "127.0.0.1" }, storage: { dbPath: "/usr/local/var/mongodb" }, systemLog: { destination: "file", logAppend: true, path: "/usr/local/var/log/mongodb/mongo.log" } } 2020-04-16T16:54:03.387+0100 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock Permission denied 2020-04-16T16:54:03.387+0100 F - [initandlisten] Fatal Assertion 40486 at src/mongo/transport/transport_layer_asio.cpp 684 2020-04-16T16:54:03.387+0100 F - [initandlisten] ***aborting after fassert() failure 
2
  • I can see there is permission denied on the socket, could you please give permissions. Commented Apr 16, 2020 at 16:32
  • @Abhishekkumar I don't know how to do that. Could you please tell me how? ilies-mbp:mongodb iliebogdanbarbulescu$ ls -ld /tmp lrwxr-xr-x@ 1 root admin 11 8 Jan 19:28 /tmp -> private/tmp ilies-mbp:mongodb iliebogdanbarbulescu$ ls -ls /tmp/mongodb-27017.sock 0 srwx------ 1 root wheel 0 16 Apr 16:20 /tmp/mongodb-27017.sock Commented Apr 16, 2020 at 17:49

2 Answers 2

1

Thanks to @Abhishek kumar , after changing the permission on the .sockfile, I could start the client with the command mongo

  • set the permissions of the .sock file to the current user:

    sudo chown whoami /tmp/mongodb-27017.sock

Sign up to request clarification or add additional context in comments.

Comments

0

So, we can conclude this post with the solution to check the .sock file permission and change the permission of the .sock file.

 Change the permission of .sock file. 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.