Unable to Connect to my mongoDB database

I am at the chapter of basic security and I am unable to connect to mongo shell at all with all the commands, mongod is started in background.

mongo
MongoDB shell version v3.6.16
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
2020-01-27T04:23:44.591+0000 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2020-01-27T04:23:44.591+0000 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:263:13
@(connect):1:6

mongo admin --port 27017 -u m103-admin -p m103-pass --host 127.0.0.1:27017
MongoDB shell version v3.6.16
connecting to: mongodb://127.0.0.1:27017/admin?gssapiServiceName=mongodb
2020-01-27T04:24:49.776+0000 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2020-01-27T04:24:49.776+0000 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:263:13
@(connect):1:6

mongo admin --port 27017 -u m103-admin -p m103-pass --host 127.0.0.1
MongoDB shell version v3.6.16
connecting to: mongodb://127.0.0.1:27017/admin?gssapiServiceName=mongodb
2020-01-27T04:24:54.179+0000 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2020-01-27T04:24:54.179+0000 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:263:13
@(connect):1:6

Hi @Sachin_54317,

Do you have a mongod instance running on port 27017 ?

You can list the currently running mongod instances on your system by running this command :

 ps -ef | grep mongod 

Hope it helps!

Thanks,
Shubham Ranjan
Curriculum Services Engineer

Hi @Shubham_Ranjan,
I too have similar issue. Mongod instance is runnning on port 27000. But when I try to connnect to this port I am facing issue.

image

By specifying –bind_ip 192.168.103.100 you explicitly ask mongod not to listen on 127.0.0.1.

Hi @Jishnu_89658,

In addition to @steevej-1495,

Please read the question carefully. You have to bind these two IPs together : 192.168.103.100 and 127.0.0.1 .

Please check our documentation on mongod for more information.

Thanks,
Shubham Ranjan
Curriculum Services Engineer