Mongosh command not working and entering shell

Hi does anyone have a solution to my problem. Whenever I type mongosh into my terminal this is the error I keep getting

mongosh
Current Mongosh Log ID: 63c4361ece45dfaa717549a9
Connecting to: **mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.6.2**
MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017

Any help would be nice

By default mongosh will connect to to 127.0.0.1(localhost) on port 27017.

There is no server listening at this address or the connection is being actively rejected(firewall as an example).

1 Like

Hi Chris

How should I go about resolving the issue with it being rejected

You need a mongodb server to connect to.

Start a free Atlas cluster or deploy your own.

Links for both at the page below.

Hi Chris
I’ve tried uninstalling and reinstalling mongo, using both version 5.0 and 6.0 but the error remains the same. Is there a way for me to run the mongo shell locally on my mac terminal?

You are running the shell, it is giving an error because there is no server to connect to. mongosh is like mysql, psql, sqlplus it is a client, it needs a server to connect to.

You need an Atlas cluster or a local server to get started.

Getting started with Atlas:

Installing and starting a server on macOS:

1 Like

after facing this question, I come across this thread and I found no way to solve my question. yet I have tried to search until come to know how to solve this, below is my way let me know if it works for you too:

first start the mongodb by using this command into the terminal:

service mongod start

then run:

mongosh

from here you will be able to proceed. Thank you !

1 Like