Unable to connect to the local mongodb instance to complete the Learning Activity

In the workspace IDE, i’m unable to do anything to the mongo db

When I run:
user@M150# mongod

I get this:
{"t":{"$date":"2021-08-17T06:53:04.170Z"},"s":"F", "c":"CONTROL", "id":20574, "ctx":"main","msg":"Error during global initialization","attr":{"error":{"code":8,"codeName":"UnknownError","errmsg":"Cannot get current working directory: No such file or directory"}}}

By Running:
user@M150# mongo --port 27001

I get connection refused error:
MongoDB shell version v4.4.3
connecting to: mongodb://127.0.0.1:27001/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn’t connect to server 127.0.0.1:27001, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27001 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1

Unable to find any answers to this. I can connect to my cluster and have a local db in my pc and that connection works fine.

I would try to reset the IDE workspace. I suspect the session stayed idle too long and the remote environment was terminate.

Tried that. Spent ~2 hours just trying to fix it since that IDE is going to be used in rest of the course.

Post a screenshot that show what happen exactly.

Did the reset workspace worked?

Which learning activity exactly?

The response I’ve shared is exactly what I get when I try to run the command mongod.

This post was created after resetting the ID multiple times. Resetting doesn’t work.

All learning activities but M150: Authentication and Authorization to be exact.

Here’s a video Screen Recording 2021-08-17 at 10.00.52 PM.mov - Google Drive

This is the name of the whole course. Your answer is not specific enough for us to know what you are trying to do. Your video is hard to see. There are 4 chapters in the M150 course and many activities. Which one have you completed so far? Which one are you trying to accomplish now?

I’ve already stated multiple times, with exact commands what I’m trying to do. What I’m trying to do is very simple, connect or close a running mongodb local instance on the provided IDE on the website - nothing fancier than that. I’m getting error that states connection refused. That’s a clear error message. I fix that on my pc but not on that IDE.

It’s absolutely clear what I’m trying to do in that video. Since whatever I’m sharing doesn’t align well with the “quality” content required to resolve this simple problem, maybe you could just share a screenshot where you can successfully connect to the mongodb Instance in the IDE? A local simple mongod command to connect to localhost:27001?

If you don’t understand my concern, please don’t bother to respond. I’m fine with that.

Thanks for your help

If you cannot connect, then may be it is not running.

Share the output of

ps -aef | grep [m]ongod

This is what I get:

root 37 1 0 18:13 ? 00:00:02 mongod --port 27000 --dbpath /var/mongodb/db --logpath /var/mongob/logs/mongod.log --logappend --fork

Okay. So you have 1 mongod running at port 27000.

If you want to connect you have to use

mongo --port 27000

You were try to connect at 27001. Hence, connection refused.

Yes, that worked.

Appreciate the help

I am facing same issue. tried multiple times…

user@M150# cat ~/workspace/mongod.conf
storage:
  dbPath: /var/mongodb/db
net:
  bindIp: localhost
  port: 27000
systemLog:
  destination: file
  path: /var/mongodb/logs/mongod.log
  logAppend: true
processManagement:
  fork: true
security:
  authorization: enabled

user@M150# ps -aef | grep [m]ongod
user@M150# pgrep mongod
user@M150# mongod -f ~/workspace/mongod.conf
{"t":{"$date":"2021-08-20T21:05:14.355Z"},"s":"F",  "c":"CONTROL",  "id":20574,   "ctx":"main","msg":"Error during global initialization","attr":{"error":{"code":8,"codeName":"UnknownError","errmsg":"Cannot get current working directory: No such file or directory"}}}
user@M150#

Please try mongod --config to run the mongo daemon.

Then: mongo --port 27000

This should work.

Both -f or --config should work

Did it not help resetting the workspace?

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.