Can't open mongo shell in GoormIDE

When I run mongod --dbpath data database running…


But when I try to open the mongo shell using mongo to make changes inside the database, it’s not working.

root@goorm:/workspace# mongo
MongoDB shell version v4.0.22
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
2021-03-08T17:13:30.902+0000 E QUERY    [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketExcepti
on: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:356:17
@(connect):2:6
exception: connect failed

Please let me know where I’m making mistakes.

Okay, it was my fault :neutral_face:
Here is how I fix.
First
Open terminal and use this command(Remember about Note) ,
mongod --dbpath data
Second
Run the app.js file from project’s directory
For me it was, node app.js
1
Finally,
Use mongo command from the up above directory of data,
mongo

Note:
There should have a directory named data from where you are calling mongo. In my case, data is a directory inside workspace. So, in workspace, I used mongo command.


(1) We are in the workspace.
(2) We have data directory inside the workspace.
(3)After that, we use the mongo command from workspace directory.

That’s it.
Helpful Article,