Upgrade MongoDB 4.x -> 5, MacOS, ECONNREFUSED 127.0.0.1:27017

Hello.

Just upgraded MongoDB on macOS Big Sur from v4 to v5 and now I can’t connect to MongoDB. Got following issue:

MongoDB shell version v5.0.0
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
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@src/mongo/shell/mongo.js:372:17
@(connect):2:6
exception: connect failed
exiting with code 1

I use brew. Also, from the logs I see:

“msg”:“Wrong mongod version”,“attr”:{“error”:"UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: Location4926900: Invalid featureCompatibilityVersion document in admin.system.version: { _id: “featureCompatibilityVersion”, version: “4.2” }

docs.mongodb.com/v5.0/release-notes/4.4/#upgrade-procedures doesn’t help for me as even MongoDB is not running.

Running in terminal: ps -ef | grep mongod gives a feedback that mongod is not running.

How do I change the value of featureCompatibilityVersiondocument when MongoDB is not running? I guess first would be good to resolve Connection Refused issue.

I am getting stuck now where to look. Any tip would be much appreciated.

Adding info that running mongo-community through brew gave me:

==> Successfully stopped mongodb-community (label: homebrew.mxcl.mongodb-community)
==> Successfully started mongodb-community (label: homebrew.mxcl.mongodb-community)

Seems the only way to resolve issue was to:

  1. Create backup of the content specified under dbPath from mongod.conf.
  2. Stop mongodb-community (brew services stop mongodb-community).
  3. Remove whole content specified under dbPath. In my case it was: /usr/local/var/mongodb.
  4. Restart the computer (just in case).

Then MongoDB started working. Since I didn’t have anything important to me it is fine, but it would be good to get some quick feedback on how to restore previously backed up data.

Hope this helps someone.

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