Binding specific ips with Mongodb
1
vote
1
answer
4338
views
I am using Mongodb 3.6.3 on Centos 7.
I am running the below command:
sudo mongod --storageEngine wiredTiger --dbpath /data --bind_ip_all --logpath /var/log/mongodb/mongod.log --fork
and everything will work just fine. Except, binding all is not secure enough.
I used to received a logging error when I tried --bind_ip 127.0.0.1,privateIP
but discovered that the error would disappear when I did bind_ip [127.0.0.1,privateIP]
.
However, when I tried to connect to mongo locally it would fail and through a my site, it would sit there until it timed out. I checked sudo netstat -plnt | egrep mongod
and then nothing showed up, which although it successfully forked the mongod process, it did not bind to any of the specified ips.
For reference, when I tried the same command on on the --bind_ip_all
version it returned tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 1645/mongod
.
My question is, why did --bind_ip ips
fail to bind to the specified ips?
Side Note - when binding ips, should I bind my elastic ip or my private one?
Asked by Brandon
(235 rep)
Mar 22, 2018, 04:30 PM
Last activity: Aug 12, 2020, 03:16 PM
Last activity: Aug 12, 2020, 03:16 PM