Error connecting to localhost:30000

I am trying to connect mongo using port and localhost, but I always have this problem (error).


I did a search for everything I could find on the internet, but nothing helps. What could be the mistake? Perhaps I am not correctly identifying the host?

MongoDB shell version v4.4.1
I installed Mongo using brew
I have macOS Big Sur 11.0.1

Is your mongod up and running on port 30000 on your local host?
On unix systems you can check
ps -ef|grep mongod

What should I check? I entered this command and was given this
Снимок экрана 2020-11-21 в 16.17.29

The first question is why port 30000 ? The default port for mongo is 27017.

When mongod is running with default configuration on your local machine running mongo is enough to connect to it.

In my task I need to use this port, when I use 27017 its works.

in default configuration mongod always running in the background on port 27017 as service
So you just issue mongo to connect

But if you want to connect a mongod running on a different port firt you need to bring up your mongod
mongod --port 30000 --dbpath provide_valid_path --logpath provide_valid_path
Please check documenation for various options like auth etc
Once mongod is up you can check with ps -ef|grep mongod
You will see mongod process
Then you can connect with
mongo --port 30000

2 Likes

It would be a good thing for your learning to be acquainted with the different options available to start mongod.

and

1 Like