The real key there is the rm -rf /usr/local/var/mongodb which deletes that old timey 3.2 data. $ ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents A more distilled version of what I specifically needed is as follows: $ brew uninstall mongodb That's where this short article saved me.
#BREW INSTALL MONGODB ERROR UPGRADE#
You'll need to read the docs in that screaming error and follow the upgrade process step by step. If you DO care about your data what follows is not for you. Nuke MongoDB from orbit and reinstall from scratch. Turns out, I don't give a shit about my local data. My data is stuck in the olden days of 3.2 and I'm trying to run 4.0. ** IMPORTANT: UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.6 before attempting an upgrade to 4.0 see for more details.īingo.
$ cat /usr/local/var/log/mongodb/mongo.log Perhaps mine lies there as well, let's find out.
I come across this issue and after scrolling for a good long while there's finally the suggestion to check the logs and, low and behold, that's where the guy's problem lies. It connects just fine, wtf!? I'm still actually confused why running mongod manually worked. So, then I try firing up the server manually via mongod and running mongo from a new tab. What does look like? $ cat ~/Library/LaunchAgents/ Users/carterbancroft/Library/LaunchAgents/: service already loaded Hmm, maybe the launch agent didn't start properly? Let's try loading it by hand: $ launchctl load ~/Library/LaunchAgents/ The obvious cause here is that the mongo server is not running (see: ps aux | grep mongo). T15:26:36.579-0800 E QUERY 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 failed I was surprised, however, to get the following error when running mongo: $ mongo The launch agent should load on system start and mongod should be running. In an perfect world this would be everything. plist into my user's launch agents directory like so: $ ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents It all starts with: $ brew uninstall brew install mongodbĪt this point, the MongoDB server can be started with the mongod command but I wanted it to fire up on startup and the installation kindly provides a launch agent for that. In my case however, I didn't care about the data, but let's take a step back.
You need to make smaller moves, first to 3.4, then to 3.6 then to 4.0. The data itself also needs to go through the upgrade process and you can't upgrade from 3.2 directly to 4.0. Spoiler alert, it turns out that if you have database data under an old version (like I did) this ain't gonna work. Today I upgraded my local MongoDB installation using Homebrew from v3.2 straight to v4.0. I'm writing this gist of an article because I'm almost certainly going to have this problem again. mongodb gist Fixing My Stupid Broken MongoDB Install in OSX.