Error: couldn‘t connect to server, connection attempt failed: SocketException: Error

created at 08-27-2021 views: 11

The problem encountered when installing mongodb on mac today, the simple problem is that there is a problem when the log is created
Then execute the command

mongod --dbpath /usr/local/var/mongodb --logpath /usr/local/var/log/mongodb/mongo.log --fork

the output is:

ERROR: child process failed, exited with 1

So this creation is unsuccessful, we need to create with the administrator's authority.

sudo mongod --dbpath /usr/local/var/mongodb --logpath /usr/local/var/log/mongodb/mongo.log --fork

then you can type mongo to check:

> mongo

MongoDB shell version v5.0.2
connecting to: mongodb:
created at:08-27-2021
edited at: 08-27-2021: