1

I am trying to connect with mongodb, But it is giving me error.

MongoDB shell version: 3.2.22 connecting to: test 2019-09-07T05:17:09.460+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused 2019-09-07T05:17:09.461+0000 E QUERY
[thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : connect@src/mongo/shell/mongo.js:229:14 @(connect):1:6

Tried:

sudo nano /etc/mongod.conf
  1. Commenting bindip
#network interfaces
net:
 port : 2701
#bindip = [0.0.0.0]
  1. Setting up this to
#network interfaces
net:
 port : 2701
bindip : 0.0.0.0
  1. Setting up this to
#network interfaces
net:
 port : 2701
bind_ip = 0.0.0.0
  1. Setting up this to
#network interfaces
net:
 port : 2701
bindip = [0.0.0.0]

Saved this file then :

sudo service mongod restart mongo 

Again connection refused giving same error :

MongoDB shell version: 3.2.22 connecting to: test 2019-09-07T05:17:09.460+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused 2019-09-07T05:17:09.461+0000 E QUERY
[thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : connect@src/mongo/shell/mongo.js:229:14 @(connect):1:6

Any Help?

Pacifist
  • 3,025
  • 2
  • 12
  • 20
Darlo
  • 11
  • 3

2 Answers2

0

Just curious, Did you enable the AWS security group for that port since you are connecting remotely?

https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html#VPCSecurityGroups

Ani Aggarwal
  • 361
  • 4
  • 16
0

try with below script :

mongod --fork --logpath /opt/app/mongo/mongod.log --auth --port 27017 --dbpath /var/lib/mongodb --bind_ip_all
David Buck
  • 3,752
  • 35
  • 31
  • 35