skip to Main Content

I restarted my computer to try to update it, and before restarting, I was also working on another project. Now, my project with a node.js backend is giving me this error:

reason: TopologyDescription {
    type: 'Single',
    setName: null,
    maxSetVersion: null,
    maxElectionId: null,
    servers: Map(1) {
      'localhost:27017' => ServerDescription {
        address: 'localhost:27017',
        error: Error: connect ECONNREFUSED 127.0.0.1:27017
            at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1132:16) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 58154302,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      }
    },
    stale: false,
    compatible: true,
    compatibilityError: null,
    logicalSessionTimeoutMinutes: null,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    commonWireVersion: null
  }

and my mongodb compass is giving me: connect ECONNREFUSED 127.0.0.1:27017. My operating system is macOS Big Sur.

In another post someone suggested restarting the mongod process and connecting again. I tried following those instructions mac-mongodb, but when I go to ‘From a new terminal, issue the following: mongosh‘ my terminal gave me command not found: mongosh. I also tried testing it with PATH="/usr/local/opt/[email protected]/bin" mongo MongoDB shell version v4.4.13 and I still got Error: couldn't connect to server 127.0.0.1:27017, with connection refused.

Does anyone know how to fix this? I would really appreciate any help or advice. Thank you!

2

Answers


  1. It may be happened due to the mongoDB server stopped. To resolve this, go to task manager. In the top bar, click Services. Search mongoDB in the set up files. If the status is "Stopped". Give a right click and start running the server. It will work again. For confirming this action, open the cmd and type mongosh and youll be getting the connection result.

    Login or Signup to reply.
  2. Restarting mongodb helped me:

    brew services stop [email protected]
    
    brew services start [email protected]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search