Reputation: 12024
I changed bindIp setting to
bindIp: 127.0.0.1, 0.0.0.0
in mongod.conf on my ubuntu server hosted on Linode and restarted mongod and status looks ok.
I opened mongodb port on ufw
sudo ufw status Status: active
To Action From -- ------ ---- 22/tcp ALLOW Anywhere 10000
ALLOW Anywhere Nginx Full
ALLOW Anywhere 3333
ALLOW Anywhere 27017
ALLOW Anywhere 22/tcp (v6)
ALLOW Anywhere (v6) 10000 (v6)
ALLOW Anywhere (v6) Nginx Full (v6)
ALLOW Anywhere (v6) 3333 (v6)
ALLOW Anywhere (v6) 27017 (v6)
ALLOW Anywhere (v6)
Connecting to it from my mac throws error:
mongo mongodb://admin:secret@ubuntuipaddress/fielddb?authSource=admin MongoDB shell version v3.6.2 connecting to: mongodb://ubuntuipaddress/fielddb?authSource=admin 2018-04-08T13:47:32.212 W NETWORK [thread1] Failed to connect to ubuntuipaddress:27017, in(checking socket for error after poll), reason: Connection refused 2018-04-08T13:47:32.214 E QUERY
[thread1] Error: couldn't connect to server ubuntuipaddress:27017, connection attempt failed : connect@src/mongo/shell/mongo.js:251:13 @(connect):1:6 exception: connect failed
How to fix this issue?
Upvotes: 1
Views: 7887
Reputation: 39
The basic steps for enabling remote access for Mongodb running on Ubuntu are:
bind_ip = 0.0.0.0
port = 27017
auth = true
are set (and uncommented)
You should be good to go.
Upvotes: 2
Reputation: 12024
The problem was wrong setting of bindIP in mmongod.conf. Changing to:
bindIp: 127.0.0.1,ip_address_of_host_running_mondgod
fixed the problem. Replace ip_address_of_host_running_mondgod with ip address of host running mongod like 137.142.177.4
Upvotes: 1
Reputation: 56
Disable your firewall and try to see if you can connect, if you can then it's your fw rules. Try this first to see if this helps.
Upvotes: 1