Can't connect to mongo

Hello everyone !
I have followed the instructions on how to install MongoDB Enterprise on mac Install MongoDB Enterprise on macOS — MongoDB Manual
but when I run mongo command, I get this error: Error: couldn’t connect to server 127.0.0.1:27017, connection attempt failed


Could you please help ?

Hi,

As many pieces of software MongoDB has a client and a server. The names of the pieces are:

  • mongo a client to connect to a mongod server (aka the database) by using a connection string (an IP).
  • mongod a server waiting for connections.

Hence to connect from mongo to the server mongod, you need to initialize the server in your computer, or connect to an already running server.

There are full courses i.e M103 for that. The first chapter would be enough to get the idea (and can be done in a day).

To connect to M121 though, where the server is running for you in the cloud, they provide the connection string:

mongo "mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/aggregations?replicaSet=Cluster0-shard-0" --authenticationDatabase admin --ssl -u m121 -p aggregations --norc

Pasting that or a modification using bin % mongo etc... should do.

I’m sorry to throw in so many terms but it’s standard terminology here…

Thank you for your help !