I recently completed the m001 basics course on Mongo University and connecting to Atlas with the connection string was not a problem. With experimenting I messed up and now I am not able to start mongo. The steps I followed are (from my root directory):
brew doctor --verbose
to make sure Homebrew is running correctly and there were no issues.
HomeBrew version: 3.0.1,
macOs: 11.1,
Homebrew Cask Staging Location: /usr/local/Caskroom
Homebrew Cask Taps: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask (3823 casks)
/usr/bin/xattr
brew cleanup
brew update
brew tap mongodb/brew
Mongo Docs installation
brew install [email protected]
Already downloaded: /Users/kevinturney/Library/Caches/Homebrew/downloads/269692f6b2d908000ecd7602021f4826947a782576c1fea760d25ece5ccbb521--mongodb-macos-x86_64-4.4.3.tgz
brew services start [email protected]
Service mongodb-community
already started, use brew services restart mongodb-community
to restart.
brew services restart mongodb-community
==> Successfully stopped mongodb-community
(label: homebrew.mxcl.mongodb-community)
==> Successfully started mongodb-community
(label: homebrew.mxcl.mongodb-community)
brew services list
Here is the error:
Name | Status | User | Plist |
---|---|---|---|
mongodb-community | error | kevinturney | /Users/kevinturney/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist |
mysql | stopped | ||
postgresql | stopped | ||
redis | stopped | ||
unbound | stopped |
I checked the processes,
MongDB University-processes
ps -ef | grep mongo
501 10770 81999 0 10:34AM ttys007 0:00.00 grep mongo
ps -ef | grep mongod
501 10776 81999 0 10:34AM ttys007 0:00.00 grep mongod
ps -ef | grep mongos
01 10781 81999 0 10:34AM ttys007 0:00.00 grep mongos
mongo --version
MongoDB shell version v4.2.2
git version: a0bbbff6ada159e19298d37946ac8dc4b497eadf
allocator: system
modules: enterprise
build environment:
distarch: x86_64
target_arch: x86_64
mongod --version
db version v4.2.2
git version: a0bbbff6ada159e19298d37946ac8dc4b497eadf
allocator: system
modules: enterprise
build environment:
distarch: x86_64
target_arch: x86_64
When I run brew services start mongodb-community
it successfully starts and then
mongo
this is the result:
kevinturney / $ brew services start mongodb-community
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-community)
kevinturney / $ mongo
MongoDB shell version v4.2.2<br/>
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb<br/>
2021-02-17T11:37:32.192-0500 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, <br/>connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:341:17<br/>
@(connect):2:6
2021-02-17T11:37:32.195-0500 F - [main] exception: connect failed
2021-02-17T11:37:32.195-0500 E - [main] exiting with code 1
I followed a very similar StackOverflow question, went though mongo docs, uninstalled, reinstalled, Also, tried this great post I am not sure what to try next.
Once you are assured that your MongoDb directory has all the required permissions, open the terminal application on your Mac and type the command, ~/mongodb/bin/mongod to start the Mongo Server. In another terminal window, type the command ~/mongodb/bin/mongo in order to start the Mongo Shell.
If you are using macOS Catalina / BigSur Above this fix will work:
Go to command line and execute these commands, you need to use SUDO else this will not work.
We first remove the folder mongodb,
sudo rm -rf /usr/local/var/mongodb
then, we add it manually,
cd /usr/local/var && mkdir mongodb
Now, we run the brew service as below, please mention the mongodb version at the end, as below:
brew services start [email protected]
If you get below response please restart the service,
Service `mongodb-community` already started, use `brew services restart mongodb-community` to restart.
To restart the service use below, please mention the mongodb version at the end:
brew services restart [email protected]
Stopping `mongodb-community`... (might take a while)
==> Successfully stopped `mongodb-community` (label: homebrew.mxcl.mongodb-commu
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-commu
Now we list all services, with below command:
brew services list
Output:
Name Status User Plist
mongodb-community started xxx homebrew.mxcl.mongodb-community.plist
Open your Terminal and type mongod –version
to verify your installation.
Could be permission issues Check ownership of /tmp/mongodb-27017.sock Try to remove this file and start the service again
via:https://www.mongodb.com/community/forums/t/help-brew-mongodb-community-5-0-error-macos/125648
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With