0

I have this mongo.zip installed in my win 10.

I have set the environment path with bin.

Somehow whenever I start command line, my mongo cannot start without mongod first.

C:\Users\asus>mongo
MongoDB shell version v4.4.1
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 :: No connection could be made because the target machine actively refused it. :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1

but if I run mongod before mongo, mongo is running perfectly.

So, my question is: how do I running mongo without mongod locally.

PS. my compass is running and can connect to AWS cloud.

Please provide pictures if you can.

Thank you!

Bob Arnson
  • 21,377
  • 2
  • 40
  • 47
rulisastra
  • 311
  • 1
  • 2
  • 14

1 Answers1

1

I think you, first of all, you have to know about the difference between them.

Mongod is the process of MongoDB.

Mongo is a shell. You can use it to connect and run any mongo command on any MongoDB.

So, your error means;

You are trying to connect your own MongoDB with typed mongo, because the default -host parameter is localhost. But your mongod process is not running. So you have to start it.

connecting to: mongodb://127.0.0.1:27017

127.0.0.1:27017 equals localhost.

If you have MongoDB (mongod process) on AWS. You should connect with below command

mongo --host mongodb0.example.com:28015
Yunus UYANIK
  • 249
  • 2
  • 13
  • so, it means: it won't run the local database just by typing ```mongo``` in shell? I should run both of them? – rulisastra Nov 03 '20 at 08:45
  • Not every time, just check out your service status and if stopped you have to run it. Use this code `service mongod status` – Yunus UYANIK Nov 03 '20 at 17:41
  • thank you! I can run just `mongo`, but not every time. I think you're right. It's because of the service status. Thank you! – rulisastra Nov 15 '20 at 10:00