Hello,
I recently upgraded my Macbook Air M1 2020 to Ventura 13.1 OS. Once the software update was finished, my backend would no longer connect to my MongoDB database. I have spent several days trying all ways of debugging without any luck. Hoping maybe someone had the same issue.
This is what my terminal looks like when I try to run my backend
~/Cinderblox/Cinderblox_Backend (main*) » npm start daenamcclintock@Daenas-MacBook-Air
> cinderblox@1.0.0 start
> node server.js
listening on port 8000
THIS IS THE CONNECTION ERROR MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
at Connection.openUri (/Users/daenamcclintock/Cinderblox/Cinderblox_Backend/node_modules/mongoose/lib/connection.js:825:32)
at /Users/daenamcclintock/Cinderblox/Cinderblox_Backend/node_modules/mongoose/lib/index.js:409:10
at promiseOrCallback (/Users/daenamcclintock/Cinderblox/Cinderblox_Backend/node_modules/mongoose/lib/helpers/promiseOrCallback.js:11:14)
at Mongoose._promiseOrCallback (/Users/daenamcclintock/Cinderblox/Cinderblox_Backend/node_modules/mongoose/lib/index.js:1262:10)
at Mongoose.connect (/Users/daenamcclintock/Cinderblox/Cinderblox_Backend/node_modules/mongoose/lib/index.js:408:20)
at Object.<anonymous> (/Users/daenamcclintock/Cinderblox/Cinderblox_Backend/server.js:38:10)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Module._load (node:internal/modules/cjs/loader:922:12) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) { '127.0.0.1:27017' => [ServerDescription] },
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined
}
/Users/daenamcclintock/Cinderblox/Cinderblox_Backend/node_modules/mongoose/lib/helpers/promiseOrCallback.js:21
throw error;
^
Error: Connect error to MongoDB
at /Users/daenamcclintock/Cinderblox/Cinderblox_Backend/server.js:43:9
at /Users/daenamcclintock/Cinderblox/Cinderblox_Backend/node_modules/mongoose/lib/helpers/promiseOrCallback.js:18:13
at /Users/daenamcclintock/Cinderblox/Cinderblox_Backend/node_modules/mongoose/lib/index.js:411:16
at /Users/daenamcclintock/Cinderblox/Cinderblox_Backend/node_modules/mongoose/lib/connection.js:843:14
at runNextTicks (node:internal/process/task_queues:60:5)
at listOnTimeout (node:internal/timers:533:9)
at process.processTimers (node:internal/timers:507:7)
Node.js v19.3.0
When I run ‘brew services list’ it shows that my mongodb-community is not connecting.
~/Cinderblox/Cinderblox_Backend (main*) » brew services list 1 ↵ daenamcclintock@Daenas-MacBook-Air
Name Status User File
mongodb-community error 15872 root ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist
mongodb-community@4.4 error 12288 daenamcclintock ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community@4.4.plist
when I try to connect to Mongosh, I get the error: connect ECONNREFUSED 127.0.0.1:27017
~/Cinderblox/Cinderblox_Backend (main*) » mongosh daenamcclintock@Daenas-MacBook-Air
Current Mongosh Log ID: 63b549491509be2622a61dcb
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.6.1
MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017
I have tried restarting mongodb-community
/ » brew services restart mongodb/brew/mongodb-community daenamcclintock@Daenas-MacBook-Air
Stopping `mongodb-community`... (might take a while)
==> Successfully stopped `mongodb-community` (label: homebrew.mxcl.mongodb-community)
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-community)
I also tried upgrading brew and reinstalling mongodb-community, all without luck.
Please let me know if anyone knows how to solve this issue.
Thanks