Running mongod from the terminal - macos


I install mongoDB according to this page

I created the files and folders necessary, and gave appropriate rights.
Then, at step 4, when I try to run mongoDB, I get the following error in the log file:
{“t”:{"$date":“2022-07-26T15:58:36.684+02:00”},“s”:“E”, “c”:“CONTROL”, “id”:20568, “ctx”:“initandlisten”,“msg”:“Error setting up listener”,“attr”:{“error”:{“code”:9001,“codeName”:“SocketException”,“errmsg”:“Address already in use”}}}

Could you please help?

thank you

You have another instance of mongod listening at the same address and port.

thank you. Does that explain why when I run the next line: mongosh, I get “command not found”?

No it does not.


I’m sorry, I just realized this answer does not in fact solve my issue completely. I am following course M121, which requires me to install the enterprise version of mongoDB. For this version, it seems I cannot use homebrew. As explained initially, I had started to download the tgz, but got stuck at step 4, when my terminal indicated mongosh not found.

For this, you have to find where exactly mongosh was installed. And then make sure you $PATH includes this directory.

The MongoDB shell (mongosh) is a completely different download. This does not come with either the Enterprise or Community version of MongoDB server. This can be installed using brew as well if you don’t want to use the zip file.

As for installing Enterprise, you should be able to install that with brew as well:

brew tap mongodb/brew
brew install mongodb-enterprise

The above taken from the project’s github page. They don’t talk about installing Enterprise on that page, but if you look at the Forumla directory you will see it includes Enterprise versions.

Make sure you don’t have Community installed or you’ll run into a conflicting package issue.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.