Mongo connection failed

Had my vagrant set up and running properly. mongod --version shows up all the right values. When I try to get into mongo shell using mongo command, following error shows up -

MongoDB shell version v3.6.12
connecting to: mongodb://
2019-06-22T12:14:50.986+0000 W NETWORK  [thread1] Failed to connect to, in(checking socket for error after poll), reason: Connection refused
2019-06-22T12:14:50.991+0000 E QUERY    [thread1] Error: couldn't connect to server, connection attempt failed :
exception: connect failed

Can someone help me out please.

Did it work before?I mean in basics course as you are in cluster admin course now
You are trying to connect to default port.It should allow
May be firewall issues/antivirus issues preventing?
Did you try from another location
Please check our forums.You will get help

Did you start a mongod process first? mongo is just a shell command tool, you need to start the server using mongod for mongo to work.

Also, make sure you are specifying the right --port.

Once I start the mongod process, it doesn’t let me put any other commands afterwards. I tried doing mongod --> mongo and that it didn’t do anything.

mongod will lock up the current terminal for logging. To avoid that use --fork in the command line, for example:

mongod --auth --port 27000 --bind_ip ',' --dbpath /data/db --logpath /data/log/mongod.log --fork

Or, use this option in the conf file

  fork: true
  destination: file
  path: <path-to-logging-file>
  logAppend: true

I would suggest you re-watch the week1 mongod videos for detailed instructions about forking mongod processes and creating logging path.

@Ramachandra_37567 Yes, it did work before when I worked on M001 and M220 course. I’ll probably search the forums as you said.

ssh to vagrant environment …start then mongod process
then ssh to vagrant environment from another terminal…and connect to mongo shell.

i was also getting same problem while connecting the mongo shell from local terminal.

Early in the first videos this caveat is explained. Someone had the same misunderstanding here and there are several ways to go about this process… Follow this link:

Running MongoD Problem

The error stack shows that you’re trying to connect on port 27017. Throughout chapter 1 we’ve been instructed to use port 27000. Perhaps that’s the reason. If mongod is using port 27000 and you try to connect via mongo on port 27017 the connection request will fail.