sudo nano /etc/mongod.conf
Find the network interfaces
section, then the bindIp
value:
. . . # network interfaces net: port: 27017 bindIp: 127.0.0.1 . . .
Append a comma to this line followed by your MongoDB server’s public IP address:
. . . # network interfaces net: port: 27017 bindIp: 127.0.0.1,mongodb_server_ip . . .
Please note that this should be the IP address of the server on which you’ve installed MongoDB, not the IP address of your trusted remote machine.
sudo systemctl restart mongod